aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bash/bash_completion.d/kill.bash15
-rw-r--r--bash/bashrc.d/completion.bash2
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