mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-07 12:05:34 +00:00
feat(shell): add separate history binding for zsh integration (#183)
This commit is contained in:
parent
537f738424
commit
0b5facca6a
@ -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
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user