aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/__fish_complete_job_pids.fish
diff options
context:
space:
mode:
authorGravatar Daniel Matz <daniel.matz@gmail.com>2015-11-24 20:30:25 -0600
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2015-11-27 16:07:16 -0800
commitc2c4fbf206a6d6b61dcec21b2a4afab91bfe2c17 (patch)
treecfe70fdd612308d9c3dd49475571a9f6a7407da7 /share/functions/__fish_complete_job_pids.fish
parentbf86a92596d6486fe30acb73d4bea6edda9d3df1 (diff)
Add a function to complete job PIDs.
Diffstat (limited to 'share/functions/__fish_complete_job_pids.fish')
-rw-r--r--share/functions/__fish_complete_job_pids.fish13
1 files changed, 13 insertions, 0 deletions
diff --git a/share/functions/__fish_complete_job_pids.fish b/share/functions/__fish_complete_job_pids.fish
new file mode 100644
index 00000000..056e061f
--- /dev/null
+++ b/share/functions/__fish_complete_job_pids.fish
@@ -0,0 +1,13 @@
+function __fish_complete_job_pids --description "Print a list of job PIDs and their commands"
+ if set -l jobpids (jobs -p)
+ # when run at the commandline, the first line of output is a header, but
+ # that doesn't seem to be printed when you run jobs in a subshell
+
+ # then we can use the jobs command again to get the corresponding
+ # command to provide as a description for each job PID
+ for jobpid in $jobpids
+ set -l cmd (jobs -c $jobpid)
+ printf "%s\tJob: %s\n" $jobpid $cmd
+ end
+ end
+end