mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2025-01-22 22:58:26 +00:00
Add bash completion for kill command
This commit is contained in:
parent
b2bb22d883
commit
bd2763d863
12
README.md
12
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]**<TAB>`
|
||||
|
||||
@ -299,6 +299,14 @@ cd **<TAB>
|
||||
cd ~/github/fzf**<TAB>
|
||||
```
|
||||
|
||||
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 <TAB> or <Shift-TAB> keys
|
||||
kill -9 <TAB>
|
||||
```
|
||||
|
||||
#### Settings
|
||||
|
||||
```sh
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user