From: martin f. krafft Date: Sat, 5 Nov 2011 09:14:53 +0000 (+0100) Subject: mkdir in place X-Git-Url: https://git.madduck.net/etc/zsh.git/commitdiff_plain/2dfbee08389e20588a648f1f6ab18c0d9e04a1b9?ds=inline mkdir in place --- diff --git a/.zsh/zshrc/80_inplacemkdir b/.zsh/zshrc/80_inplacemkdir new file mode 100644 index 0000000..095200f --- /dev/null +++ b/.zsh/zshrc/80_inplacemkdir @@ -0,0 +1,28 @@ +# 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="$bufwords[iword]" + fi + [[ -z "${PATHTOMKDIR}" ]] && return 1 + 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