mirror of
https://github.com/edu4rdshl/based.fish.git
synced 2026-07-17 23:24:46 +00:00
(feat): better keybinding for fzf
# TAB: Accept the current selection but do not execute it, never # ENTER: Accept the current selection and execute it if confirmation is set
This commit is contained in:
parent
1eeb710cb7
commit
e7f2351f06
1 changed files with 16 additions and 10 deletions
|
|
@ -1,18 +1,24 @@
|
|||
function __based_fzf_popup
|
||||
set -l chosen (printf "%s\n" (__based) | fzf --height 50% --reverse --prompt='Command > ' --no-sort --exact --border)
|
||||
# TAB: Accept the current selection but do not execute it, never
|
||||
# ENTER: Accept the current selection and execute it if confirmation is set
|
||||
set -l out (__based | fzf \
|
||||
--height 50% --reverse --prompt='Command > ' \
|
||||
--no-sort --exact --border \
|
||||
--bind "tab:accept" \
|
||||
--expect tab,enter)
|
||||
|
||||
set -l key (echo $out[1])
|
||||
set -l chosen (string join "\n" $out[2..-1] | string collect)
|
||||
|
||||
if test -n "$chosen"
|
||||
if test -n "$chosen"
|
||||
commandline -r -- "$chosen"
|
||||
commandline -f repaint
|
||||
# If BASED_NO_CONFIRMATION is set to a non-zero value, execute the command immediately
|
||||
if set -q BASED_NO_CONFIRMATION; and test "$BASED_NO_CONFIRMATION" != 0
|
||||
|
||||
# Only execute if the user pressed ENTER and confirmation is set
|
||||
if test "$key" = enter; and set -q BASED_NO_CONFIRMATION; and test "$BASED_NO_CONFIRMATION" != 0
|
||||
commandline -f execute
|
||||
end
|
||||
end
|
||||
else
|
||||
commandline -f repaint
|
||||
return
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue