mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-12-28 01:09:03 +01:00
54 lines
1.0 KiB
Plaintext
54 lines
1.0 KiB
Plaintext
|
# Copy this file into /usr/share/zsh/site-functions/
|
||
|
# and add 'autoload n-history` to .zshrc
|
||
|
#
|
||
|
# This function allows to browse Z shell's history and use the
|
||
|
# entries
|
||
|
#
|
||
|
# Uses n-list
|
||
|
|
||
|
emulate -L zsh
|
||
|
|
||
|
setopt extendedglob
|
||
|
zmodload zsh/curses
|
||
|
|
||
|
local IFS="
|
||
|
"
|
||
|
|
||
|
unset NLIST_COLORING_PATTERN
|
||
|
|
||
|
[ -f ~/.config/znt/n-list.conf ] && . ~/.config/znt/n-list.conf
|
||
|
[ -f ~/.config/znt/n-history.conf ] && . ~/.config/znt/n-history.conf
|
||
|
|
||
|
local list
|
||
|
local selected
|
||
|
|
||
|
NLIST_REMEMBER_STATE=0
|
||
|
|
||
|
list=( `builtin history -rn 1` )
|
||
|
list=( "${(@M)list:#(#i)*$1*}" )
|
||
|
|
||
|
local NLIST_GREP_STRING="$1"
|
||
|
|
||
|
if [ "$#list" -eq 0 ]; then
|
||
|
echo "No matching history entries"
|
||
|
return 1
|
||
|
fi
|
||
|
|
||
|
n-list "${list[@]}"
|
||
|
|
||
|
if [ "$REPLY" -gt 0 ]; then
|
||
|
selected="$reply[REPLY]"
|
||
|
# ZLE?
|
||
|
if [ "${(t)CURSOR}" = "integer-local-special" ]; then
|
||
|
zle redisplay
|
||
|
zle kill-whole-line
|
||
|
zle -U "$selected"
|
||
|
else
|
||
|
print -zr "$selected"
|
||
|
fi
|
||
|
else
|
||
|
[ "${(t)CURSOR}" = "integer-local-special" ] && zle redisplay
|
||
|
fi
|
||
|
|
||
|
# vim: set filetype=zsh:
|