diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2016-09-05 12:56:25 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2016-09-05 12:56:25 +1200 |
commit | 015aae34735751e74d5143a3f91d88f44b19ab6e (patch) | |
tree | e97cba5cf681bd369ff5b3e44a83a8512cb02172 | |
parent | Flesh out builtin completions a little (diff) | |
download | dotfiles-015aae34735751e74d5143a3f91d88f44b19ab6e.tar.gz dotfiles-015aae34735751e74d5143a3f91d88f44b19ab6e.zip |
Complete kill builtin with jobspecs and user PIDs
-rw-r--r-- | bash/bash_completion.d/kill.bash | 15 | ||||
-rw-r--r-- | bash/bashrc.d/completion.bash | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/bash/bash_completion.d/kill.bash b/bash/bash_completion.d/kill.bash new file mode 100644 index 00000000..0aca041f --- /dev/null +++ b/bash/bash_completion.d/kill.bash @@ -0,0 +1,15 @@ +# Complete kill builtin with jobspecs (prefixed with % so it will accept them) +# and this user's PIDs (requires pgrep(1)) +_kill() { + while read -r pid ; do + case $pid in + "${COMP_WORDS[COMP_CWORD]}"*) + COMPREPLY[${#COMPREPLY[@]}]=$pid + ;; + esac + done < <( { + compgen -A job -P% + pgrep -u "$USER" . + } 2>/dev/null ) +} +complete -F _kill kill diff --git a/bash/bashrc.d/completion.bash b/bash/bashrc.d/completion.bash index 9c20d482..3e1c7bac 100644 --- a/bash/bashrc.d/completion.bash +++ b/bash/bashrc.d/completion.bash @@ -29,7 +29,7 @@ complete -A variable for getopts let read select complete -A helptopic help # Jobspecs -complete -A job disown fg jobs kill +complete -A job disown fg jobs complete -A stopped bg # Readline bindings |