Add gpgwkd function for gpg key fetches
[zsh.git] / .zsh / functions / inplaceMkDirs
1 # -*- mode:sh -*-
2 #f5# Create directory under cursor or the selected area
3 inplaceMkDirs() {
4 # Press ctrl-xM to create the directory under the cursor or the selected area.
5 # To select an area press ctrl-@ or ctrl-space and use the cursor.
6 # Use case: you type "mv abc ~/testa/testb/testc/" and remember that the
7 # directory does not exist yet -> press ctrl-XM and problem solved
8 local PATHTOMKDIR
9 if ((REGION_ACTIVE==1)); then
10 local F=$MARK T=$CURSOR
11 if [[ $F -gt $T ]]; then
12 F=${CURSOR}
13 T=${MARK}
14 fi
15 # get marked area from buffer and eliminate whitespace
16 PATHTOMKDIR=${BUFFER[F+1,T]%%[[:space:]]##}
17 PATHTOMKDIR=${PATHTOMKDIR##[[:space:]]##}
18 else
19 local bufwords iword
20 bufwords=(${(z)LBUFFER})
21 iword=${#bufwords}
22 bufwords=(${(z)BUFFER})
23 PATHTOMKDIR="${(Q)bufwords[iword]}"
24 fi
25 [[ -z "${PATHTOMKDIR}" ]] && return 1
26 PATHTOMKDIR=${~PATHTOMKDIR}
27 if [[ -e "${PATHTOMKDIR}" ]]; then
28 zle -M " path already exists, doing nothing"
29 else
30 zle -M "$(mkdir -p -v "${PATHTOMKDIR}")"
31 zle end-of-line
32 fi
33 }