# # Provide a way to list target directory contents while editing 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 # _list_inplace() { emulate -L zsh local lastarg 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 lastarg=${BUFFER[F+1,T]%%[[:space:]]##} lastarg=${pathtoview##[[:space:]]##} else local bufwords iword bufwords=(${(z)LBUFFER}) iword=${#bufwords} bufwords=(${(z)BUFFER}) lastarg="${(Q)bufwords[iword]}" fi [[ -z "${lastarg}" ]] && return 1 ls -l ${~lastarg:h} zle end-of-line } zle -N _list_inplace bindkey '\el' _list_inplace # vim:ft=zsh