diff --git a/README.md b/README.md index 88e00e7b..0f071e71 100644 --- a/README.md +++ b/README.md @@ -270,8 +270,8 @@ over time* ### bash -Fuzzy completion can be triggered if the word before the cursor ends -with the trigger sequence which is by default `**`. +Fuzzy completion for files and directories can be triggered if the word before +the cursor ends with the trigger sequence which is by default `**`. - `COMMAND [DIRECTORY/][FUZZY_PATTERN]**` @@ -299,6 +299,14 @@ cd ** cd ~/github/fzf** ``` +Fuzzy completion for PIDs are provided for kill command. In this case +there is no trigger sequence, just press tab key after kill command. + +```sh +# Can select multiple processes with or keys +kill -9 +``` + #### Settings ```sh diff --git a/fzf-completion.bash b/fzf-completion.bash index 6697b372..beb39eef 100644 --- a/fzf-completion.bash +++ b/fzf-completion.bash @@ -83,6 +83,18 @@ _fzf_dir_completion() { "" } +_fzf_kill_completion() { + local selected + tput sc + selected=$(ps -ef | sed 1d | fzf -m | awk '{print $2}' | tr '\n' ' ') + tput rc + + if [ -n "$selected" ]; then + COMPREPLY=( "$selected" ) + return 0 + fi +} + complete -F _fzf_opts_completion fzf # Directory @@ -108,3 +120,6 @@ for cmd in " complete -F _fzf_all_completion -o default -o bashdefault $cmd done +# Kill completion +complete -F _fzf_kill_completion -o nospace -o default -o bashdefault kill +