mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-17 19:30:10 +00:00
47 lines
892 B
Bash
47 lines
892 B
Bash
# Copy this file into /usr/share/zsh/site-functions/
|
|
# and add 'autoload n-aliases` to .zshrc
|
|
#
|
|
# This function allows to choose an alias 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-aliases.conf ] && . ~/.config/znt/n-aliases.conf
|
|
|
|
local list
|
|
local selected
|
|
|
|
NLIST_REMEMBER_STATE=0
|
|
|
|
list=( "${(@k)aliases}" )
|
|
list=( "${(@M)list:#(#i)*$1*}" )
|
|
|
|
local NLIST_GREP_STRING="$1"
|
|
|
|
if [ "$#list" -eq 0 ]; then
|
|
echo "No matching aliases"
|
|
return 1
|
|
fi
|
|
|
|
list=( "${(@i)list}" )
|
|
n-list "$list[@]"
|
|
|
|
if [ "$REPLY" -gt 0 ]; then
|
|
selected="$reply[REPLY]"
|
|
echo "Editing \`$selected':"
|
|
print -rs "vared aliases\\[$selected\\]"
|
|
vared aliases\[$selected\]
|
|
fi
|
|
|
|
# vim: set filetype=zsh:
|