summaryrefslogtreecommitdiff
path: root/oh-my-zsh/plugins/zsh-navigation-tools/n-env
diff options
context:
space:
mode:
authorAditya <bluenerd@protonmail.com>2023-02-27 20:04:56 +0530
committerAditya <bluenerd@protonmail.com>2023-02-27 20:04:56 +0530
commitedc449275b6c04445f58b108ca0937a87c1e8430 (patch)
tree9fd484d58145b616f29a78857cc0b1c8b1c18f05 /oh-my-zsh/plugins/zsh-navigation-tools/n-env
parent6f5424ca96c4221ef433f545642669e9c104d0ed (diff)
add zsh
Diffstat (limited to 'oh-my-zsh/plugins/zsh-navigation-tools/n-env')
-rw-r--r--oh-my-zsh/plugins/zsh-navigation-tools/n-env47
1 files changed, 47 insertions, 0 deletions
diff --git a/oh-my-zsh/plugins/zsh-navigation-tools/n-env b/oh-my-zsh/plugins/zsh-navigation-tools/n-env
new file mode 100644
index 0000000..c003b63
--- /dev/null
+++ b/oh-my-zsh/plugins/zsh-navigation-tools/n-env
@@ -0,0 +1,47 @@
+# 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="
+"
+
+[ -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
+
+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: