diff options
author | Marc Cornellà <marc.cornella@live.com> | 2015-11-30 09:50:37 +0100 |
---|---|---|
committer | Marc Cornellà <marc.cornella@live.com> | 2015-11-30 09:50:37 +0100 |
commit | afd28bf1fc22f53c4a1af3f5836ca428affb34b3 (patch) | |
tree | 9f56960cbb4e2074d405e4be587a1658a6cc2159 /plugins/zsh-navigation-tools/n-aliases | |
parent | fea74b4b34412cca1b0bc3ec232e5ec8c602ee8a (diff) | |
parent | 4c292ea2b023a331dcf1af5644487f2272d24a4d (diff) | |
download | zsh-afd28bf1fc22f53c4a1af3f5836ca428affb34b3.tar.gz zsh-afd28bf1fc22f53c4a1af3f5836ca428affb34b3.tar.bz2 zsh-afd28bf1fc22f53c4a1af3f5836ca428affb34b3.zip |
Merge pull request #4368 from psprint/master
Update Zsh Navigation Tools plugin
Diffstat (limited to 'plugins/zsh-navigation-tools/n-aliases')
-rw-r--r-- | plugins/zsh-navigation-tools/n-aliases | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/plugins/zsh-navigation-tools/n-aliases b/plugins/zsh-navigation-tools/n-aliases new file mode 100644 index 000000000..d81db9253 --- /dev/null +++ b/plugins/zsh-navigation-tools/n-aliases @@ -0,0 +1,47 @@ +# Copy this file into /usr/share/zsh/site-functions/ +# and add 'autoload n-aliases` to .zshrc +# +# This function allows to choose an alias for edition with vared +# +# Uses n-list + +emulate -L zsh + +setopt extendedglob +zmodload zsh/curses +zmodload zsh/parameter + +local IFS=" +" + +unset NLIST_COLORING_PATTERN + +[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf +[ -f ~/.config/znt/n-aliases.conf ] && . ~/.config/znt/n-aliases.conf + +local list +local selected + +NLIST_REMEMBER_STATE=0 + +list=( "${(@k)aliases}" ) +list=( "${(@M)list:#(#i)*$1*}" ) + +local NLIST_GREP_STRING="$1" + +if [ "$#list" -eq 0 ]; then + echo "No matching aliases" + return 1 +fi + +list=( "${(@i)list}" ) +n-list "$list[@]" + +if [ "$REPLY" -gt 0 ]; then + selected="$reply[REPLY]" + echo "Editing \`$selected':" + print -rs "vared aliases\\[$selected\\]" + vared aliases\[$selected\] +fi + +# vim: set filetype=zsh: |