# # Provide a way to to create directories while composing the ZLE # # Copyright © 1994–2017 martin f. krafft # Released under the terms of the Artistic Licence 2.0 # # Source repository: http://git.madduck.net/v/etc/zsh.git # _mkdir_inplace() { emulate -L zsh 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 _mkdir_inplace bindkey '\em' _mkdir_inplace # vim:ft=zsh