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

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:

add pmnpw alias
[etc/zsh.git] / .zsh / zshrc / 80-zle_inplace_list
1 #
2 # Provide a way to list target directory contents while editing ZLE
3 #
4 # Copyright © 1994–2017 martin f. krafft <madduck@madduck.net>
5 # Released under the terms of the Artistic Licence 2.0
6 #
7 # Source repository: http://git.madduck.net/v/etc/zsh.git
8 #
9
10 _list_inplace() {
11   emulate -L zsh
12   local lastarg
13   if ((REGION_ACTIVE==1)); then
14     local F=$MARK T=$CURSOR
15     if [[ $F -gt $T ]]; then
16       F=${CURSOR}
17       T=${MARK}
18     fi
19     # get marked area from buffer and eliminate whitespace
20     lastarg=${BUFFER[F+1,T]%%[[:space:]]##}
21     lastarg=${pathtoview##[[:space:]]##}
22   else
23     local bufwords iword
24     bufwords=(${(z)LBUFFER})
25     iword=${#bufwords}
26     bufwords=(${(z)BUFFER})
27     lastarg="${(Q)bufwords[iword]}"
28   fi
29   [[ -z "${lastarg}" ]] && return 1
30   ls "$@" ${~lastarg}
31   zle redisplay
32   #zle end-of-line
33 }
34 zle -N _list_inplace
35 bindkey '\el' _list_inplace
36
37 _list_inplace_time() {
38   emulate -L zsh
39   _list_inplace -rt
40 }
41 zle -N _list_inplace_time
42 bindkey '\eL' _list_inplace_time
43
44 # vim:ft=zsh
45