1
0
Fork 0
mirror of https://github.com/ohmyzsh/ohmyzsh.git synced 2024-12-25 13:51:57 +00:00
ohmyzsh/plugins/zsh-navigation-tools/n-functions

55 lines
1.1 KiB
Text
Raw Normal View History

2015-09-20 12:39:46 +00:00
# Copy this file into /usr/share/zsh/site-functions/
# and add 'autoload n-functions` to .zshrc
#
# This function allows to choose a function 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-functions.conf ] && . ~/.config/znt/n-functions.conf
local list
local selected
NLIST_REMEMBER_STATE=0
list=( "${(@k)functions}" )
list=( "${(@M)list:#(#i)*$1*}" )
local NLIST_GREP_STRING="$1"
if [ "$#list" -eq 0 ]; then
echo "No matching functions"
return 1
fi
list=( "${(@i)list}" )
n-list "$list[@]"
if [ "$REPLY" -gt 0 ]; then
selected="$reply[REPLY]"
if [ "$feditor" = "zed" ]; then
echo "Editing \`$selected' (ESC ZZ or Ctrl-x-w to finish):"
autoload zed
print -rs "zed -f -- \"$selected\""
zed -f -- "$selected"
else
echo "Editing \`$selected':"
print -rs "vared functions\\[$selected\\]"
vared functions\[$selected\]
fi
fi
# vim: set filetype=zsh: