From 015aae34735751e74d5143a3f91d88f44b19ab6e Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Mon, 5 Sep 2016 12:56:25 +1200 Subject: Complete kill builtin with jobspecs and user PIDs --- bash/bash_completion.d/kill.bash | 15 +++++++++++++++ bash/bashrc.d/completion.bash | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 bash/bash_completion.d/kill.bash (limited to 'bash') 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 -- cgit v1.2.3