Blame view

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