# from grml _inplaceMkDirs() { local PATHTOMKDIR if ((REGION_ACTIVE==1)); then local F=$MARK T=$CURSOR if [[ $F -gt $T ]]; then F=${CURSOR} T=${MARK} fi # get marked area from buffer and eliminate whitespace PATHTOMKDIR=${BUFFER[F+1,T]%%[[:space:]]##} PATHTOMKDIR=${PATHTOMKDIR##[[:space:]]##} else local bufwords iword bufwords=(${(z)LBUFFER}) iword=${#bufwords} bufwords=(${(z)BUFFER}) PATHTOMKDIR="${(Q)bufwords[iword]}" fi [[ -z "${PATHTOMKDIR}" ]] && return 1 PATHTOMKDIR=${~PATHTOMKDIR} if [[ -e "${PATHTOMKDIR}" ]]; then zle -M " path already exists, doing nothing" else zle -M "$(mkdir -p -v "${PATHTOMKDIR}")" zle end-of-line fi } zle -N _inplaceMkDirs && bindkey '^xm' _inplaceMkDirs