]> git.madduck.net Git - etc/zsh.git/blob - .zsh/zshrc/80_inplacemkdir

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

enable vcsprompt to use %-sequences and make vcsh prompt stand out
[etc/zsh.git] / .zsh / zshrc / 80_inplacemkdir
1 # from grml
2 _inplaceMkDirs() {
3     local PATHTOMKDIR
4     if ((REGION_ACTIVE==1)); then
5         local F=$MARK T=$CURSOR
6         if [[ $F -gt $T ]]; then
7             F=${CURSOR}
8             T=${MARK}
9         fi
10         # get marked area from buffer and eliminate whitespace
11         PATHTOMKDIR=${BUFFER[F+1,T]%%[[:space:]]##}
12         PATHTOMKDIR=${PATHTOMKDIR##[[:space:]]##}
13     else
14         local bufwords iword
15         bufwords=(${(z)LBUFFER})
16         iword=${#bufwords}
17         bufwords=(${(z)BUFFER})
18         PATHTOMKDIR="${(Q)bufwords[iword]}"
19     fi
20     [[ -z "${PATHTOMKDIR}" ]] && return 1
21     PATHTOMKDIR=${~PATHTOMKDIR}
22     if [[ -e "${PATHTOMKDIR}" ]]; then
23         zle -M " path already exists, doing nothing"
24     else
25         zle -M "$(mkdir -p -v "${PATHTOMKDIR}")"
26         zle end-of-line
27     fi
28 }
29 zle -N _inplaceMkDirs && bindkey '^xm' _inplaceMkDirs