Skip to content

Instantly share code, notes, and snippets.

@jackfranklin
Created August 28, 2013 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackfranklin/6367091 to your computer and use it in GitHub Desktop.
Save jackfranklin/6367091 to your computer and use it in GitHub Desktop.
I'd like to write a small shell script that takes the output of the `jobs` command, which looks like so:
[1] - suspended vim
[2] + suspended less foo.txt
And have it return a string like:
(1:vim 2:less foo.txt)
So I can add that to my PROMPT.
@mheap
Copy link

mheap commented Aug 28, 2013

echo "("`jobs | sed -r 's/ .*suspended (\(signal\))?//' | tr -s ' ' | tr '\n' ' ' | sed 's/\[\([^]]*\)\]/\1:/g'`")"

There's a trailing space that I'm working on removing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment