aboutsummaryrefslogtreecommitdiff
path: root/bash/bash_completion.d/kill.bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash/bash_completion.d/kill.bash')
-rw-r--r--bash/bash_completion.d/kill.bash15
1 files changed, 15 insertions, 0 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