I know that the jobs command only shows jobs running in current shell session.
Is there a bash code that will show jobs across shell sessions (for example, jobs from another terminal tab) for current user?
I know that the jobs command only shows jobs running in current shell session.
Is there a bash code that will show jobs across shell sessions (for example, jobs from another terminal tab) for current user?
It's unclear (to me) what you'd want this global jobs call to do beyond just listing all processes owned by the current user (ps x), but you could filter that listing by terminal and/or by state.
List your processes that are:
ps x |awk '$2 ~ /pts/'bg): ps x |awk '$3 ~ /T/'ps x |awk '$3 ~ /\+/'AWK is really powerful. Here we're just calling out fields by number and looking at their values ($) with regular expression matchers ~). These are conditions and we're simply using AWK's default action (print matches, which could also be written like { print $0 } to print the whole line).
You can add the title with 'NR == 1 || … (number of records = 1, aka line 1) in the AWK command. These can be combined, e.g. ps x |awk 'NR == 1 || $3 ~ /T/ || $2 ~ /pts/. Using regular expressions, you can combine the first two bullets as ps x |awk '$3 ~ /[T+]/'. These conditional statements are logical, so you can combine || with && and parentheses, e.g. ps x |awk 'NR == 1 || ($3 ~ /\+/ && $2 ~ /pts/)'
I suspect what you want is: ps x |awk 'NR == 1 || $2 ~ /pts/
I ran this on a Linux system. If you're running something else, your terminal emulators may be named differently. Run ps $$ to take a look at how your active shell appears on the list and build a regular expression from the second column.