From 52594355bfa63ce7d579c7961f4f2fb30b486101 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 21 Jul 2022 22:16:19 +0900 Subject: [PATCH] [shell] 'kill' completion will now require trigger sequence (**) 'kill **' instead of 'kill ' just like any other completions. Close #2716 Close #385 --- CHANGELOG.md | 2 ++ README.md | 5 ++--- shell/completion.bash | 14 ++------------ shell/completion.zsh | 6 ------ test/test_go.rb | 2 +- 5 files changed, 7 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5a8519f..31c9b827 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ CHANGELOG ``` - Use SGR mouse mode to support larger terminals - Bug fixes and improvements +- Shell extension + - `kill` completion now requires trigger sequence (`**`) for consistency 0.30.0 ------ diff --git a/README.md b/README.md index 92eab8b7..d8e11afc 100644 --- a/README.md +++ b/README.md @@ -382,12 +382,11 @@ cd ~/github/fzf** #### Process IDs -Fuzzy completion for PIDs is provided for kill command. In this case, -there is no trigger sequence; just press the tab key after the kill command. +Fuzzy completion for PIDs is provided for kill command. ```sh # Can select multiple processes with or keys -kill -9 +kill -9 ** ``` #### Host names diff --git a/shell/completion.bash b/shell/completion.bash index 681c89fb..b1e79353 100644 --- a/shell/completion.bash +++ b/shell/completion.bash @@ -260,14 +260,6 @@ _fzf_dir_completion() { } _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 "$@" } @@ -352,9 +344,6 @@ for cmd in $d_cmds; do __fzf_defc "$cmd" _fzf_dir_completion "-o nospace -o dirnames" done -# Kill completion (supports empty completion trigger) -complete -F _fzf_complete_kill -o default -o bashdefault kill - unset cmd d_cmds a_cmds _fzf_setup_completion() { @@ -377,9 +366,10 @@ _fzf_setup_completion() { done } -# Environment variables / Aliases / Hosts +# Environment variables / Aliases / Hosts / Process _fzf_setup_completion 'var' export unset _fzf_setup_completion 'alias' unalias _fzf_setup_completion 'host' ssh telnet +_fzf_setup_completion 'proc' kill fi diff --git a/shell/completion.zsh b/shell/completion.zsh index f12afca1..2577eacb 100644 --- a/shell/completion.zsh +++ b/shell/completion.zsh @@ -285,12 +285,6 @@ fzf-completion() { lbuf=$LBUFFER 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 if [ ${#tokens} -gt 1 -a "$tail" = "$trigger" ]; then diff --git a/test/test_go.rb b/test/test_go.rb index 3050fa0a..d64df315 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -2478,7 +2478,7 @@ module CompletionTest pid = lines[-1]&.split&.last tmux.prepare 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.send_keys 'sleep12345' tmux.until { |lines| assert lines.any_include?('sleep 12345') }