feat(shell): add separate history binding for zsh integration (#183)

This commit is contained in:
Alex Pasmantier 2024-12-30 16:13:19 +01:00 committed by GitHub
parent 537f738424
commit 0b5facca6a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,4 +1,4 @@
_tv_search() { _tv_smart_autocomplete() {
emulate -L zsh emulate -L zsh
zle -I zle -I
@ -9,9 +9,9 @@ _tv_search() {
output=$(tv --autocomplete-prompt "$current_prompt" $*) output=$(tv --autocomplete-prompt "$current_prompt" $*)
zle reset-prompt
if [[ -n $output ]]; then if [[ -n $output ]]; then
zle reset-prompt
RBUFFER="" RBUFFER=""
LBUFFER=$current_prompt$output LBUFFER=$current_prompt$output
@ -21,9 +21,34 @@ _tv_search() {
fi fi
} }
_tv_shell_history() {
emulate -L zsh
zle -I
zle -N tv-search _tv_search local current_prompt
current_prompt=$LBUFFER
local output
output=$(tv zsh-history --input "$current_prompt" $*)
bindkey '^T' tv-search if [[ -n $output ]]; then
zle reset-prompt
RBUFFER=""
LBUFFER=$output
# uncomment this to automatically accept the line
# (i.e. run the command without having to press enter twice)
# zle accept-line
fi
}
zle -N tv-smart-autocomplete _tv_smart_autocomplete
zle -N tv-shell-history _tv_shell_history
bindkey '^T' tv-smart-autocomplete
bindkey '^R' tv-shell-history