[shell] 'kill' completion will now require trigger sequence (**)

'kill **<tab>' instead of 'kill <tab>' just like any other completions.

Close #2716
Close #385
This commit is contained in:
Junegunn Choi 2022-07-21 22:16:19 +09:00
parent 0d06c28b19
commit 52594355bf
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
5 changed files with 7 additions and 22 deletions

View File

@ -15,6 +15,8 @@ CHANGELOG
``` ```
- Use SGR mouse mode to support larger terminals - Use SGR mouse mode to support larger terminals
- Bug fixes and improvements - Bug fixes and improvements
- Shell extension
- `kill` completion now requires trigger sequence (`**`) for consistency
0.30.0 0.30.0
------ ------

View File

@ -382,12 +382,11 @@ cd ~/github/fzf**<TAB>
#### Process IDs #### Process IDs
Fuzzy completion for PIDs is provided for kill command. In this case, Fuzzy completion for PIDs is provided for kill command.
there is no trigger sequence; just press the tab key after the kill command.
```sh ```sh
# Can select multiple processes with <TAB> or <Shift-TAB> keys # Can select multiple processes with <TAB> or <Shift-TAB> keys
kill -9 <TAB> kill -9 **<TAB>
``` ```
#### Host names #### Host names

View File

@ -260,14 +260,6 @@ _fzf_dir_completion() {
} }
_fzf_complete_kill() { _fzf_complete_kill() {
local trigger=${FZF_COMPLETION_TRIGGER-'**'}
local cur="${COMP_WORDS[COMP_CWORD]}"
if [[ -z "$cur" ]]; then
COMP_WORDS[$COMP_CWORD]=$trigger
elif [[ "$cur" != *"$trigger" ]]; then
return 1
fi
_fzf_proc_completion "$@" _fzf_proc_completion "$@"
} }
@ -352,9 +344,6 @@ for cmd in $d_cmds; do
__fzf_defc "$cmd" _fzf_dir_completion "-o nospace -o dirnames" __fzf_defc "$cmd" _fzf_dir_completion "-o nospace -o dirnames"
done done
# Kill completion (supports empty completion trigger)
complete -F _fzf_complete_kill -o default -o bashdefault kill
unset cmd d_cmds a_cmds unset cmd d_cmds a_cmds
_fzf_setup_completion() { _fzf_setup_completion() {
@ -377,9 +366,10 @@ _fzf_setup_completion() {
done done
} }
# Environment variables / Aliases / Hosts # Environment variables / Aliases / Hosts / Process
_fzf_setup_completion 'var' export unset _fzf_setup_completion 'var' export unset
_fzf_setup_completion 'alias' unalias _fzf_setup_completion 'alias' unalias
_fzf_setup_completion 'host' ssh telnet _fzf_setup_completion 'host' ssh telnet
_fzf_setup_completion 'proc' kill
fi fi

View File

@ -285,12 +285,6 @@ fzf-completion() {
lbuf=$LBUFFER lbuf=$LBUFFER
tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))} tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))}
# Kill completion (do not require trigger sequence)
if [ "$cmd" = kill -a ${LBUFFER[-1]} = ' ' ]; then
tail=$trigger
tokens+=$trigger
lbuf="$lbuf$trigger"
fi
# Trigger sequence given # Trigger sequence given
if [ ${#tokens} -gt 1 -a "$tail" = "$trigger" ]; then if [ ${#tokens} -gt 1 -a "$tail" = "$trigger" ]; then

View File

@ -2478,7 +2478,7 @@ module CompletionTest
pid = lines[-1]&.split&.last pid = lines[-1]&.split&.last
tmux.prepare tmux.prepare
tmux.send_keys 'C-L' tmux.send_keys 'C-L'
tmux.send_keys 'kill ', :Tab tmux.send_keys 'kill **', :Tab
tmux.until { |lines| assert_operator lines.match_count, :>, 0 } tmux.until { |lines| assert_operator lines.match_count, :>, 0 }
tmux.send_keys 'sleep12345' tmux.send_keys 'sleep12345'
tmux.until { |lines| assert lines.any_include?('sleep 12345') } tmux.until { |lines| assert lines.any_include?('sleep 12345') }