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