>
> Subject: (Buglet) job numbers do not get re-used (sometimes)
>
> I find this annoying because if job #1 exits for some reason (including my
> accidentally
> killing it), I can't get things back to the way they were before (other
> than by getting
> rid of all the jobs and starting over).  In particular, this means I have
> to re-train
> myself to refer to the new job as %4, when I had been used to referring to
> it as %1.


How about using an alias?

~ $ jobs -l
~ $ !sl
~ $ sleep 1000 &
[1] 30898
~ $ sleep 1000 &
[2] 30900
~ $ sleep 1000 &
[3] 30902
~ $ kill %1
~ $
[1] Terminated sleep 1000
~ $ %1
~ $
[2]- Terminated sleep 1000
~ $ jobs -l
[3]+ 30902 Running sleep 1000 &
~ $ %1
~ $
[3]+ Terminated sleep 1000
~ $ %1
%1: no such job
~ $ alias
alias %1='bgpid=$( jobs -l | awk "\$3 !~ /^(Term|Kill).+\$/ && \$2
~/^[0-9]+\$/ { print \$2; exit 0 }" ); if [[ -n ${bgpid} ]]; then kill
"${bgpid}"; else printf "%%1: no such job\n"; fi; unset bgpid'
~ $


Wiley

>

Reply via email to