]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/plugins/zsh-navigation-tools/n-aliases
...
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / plugins / zsh-navigation-tools / n-aliases
1 # Copy this file into /usr/share/zsh/site-functions/
2 # and add 'autoload n-aliases` to .zshrc
3 #
4 # This function allows to choose an alias for edition with vared
5 #
6 # Uses n-list
7
8 emulate -L zsh
9
10 setopt extendedglob
11 zmodload zsh/curses
12 zmodload zsh/parameter
13
14 local IFS="
15 "
16
17 unset NLIST_COLORING_PATTERN
18
19 [ -f ~/.config/znt/n-list.conf ] && builtin source ~/.config/znt/n-list.conf
20 [ -f ~/.config/znt/n-aliases.conf ] && builtin source ~/.config/znt/n-aliases.conf
21
22 local list
23 local selected
24
25 NLIST_REMEMBER_STATE=0
26
27 list=( "${(@k)aliases}" )
28 list=( "${(@M)list:#(#i)*$1*}" )
29
30 local NLIST_GREP_STRING="$1"
31
32 if [ "$#list" -eq 0 ]; then
33     echo "No matching aliases"
34     return 1
35 fi
36
37 list=( "${(@i)list}" )
38 n-list "$list[@]"
39
40 if [ "$REPLY" -gt 0 ]; then
41     selected="$reply[REPLY]"
42     echo "Editing \`$selected':"
43     print -rs "vared aliases\\[$selected\\]"
44     vared aliases\[$selected\]
45 fi
46
47 # vim: set filetype=zsh: