mirror of
git://git.code.sf.net/p/zsh/code
synced 2026-01-02 08:21:09 +01:00
Write history entries for jobs resumed with fg/bg; from users/3795, plus
a couple of minor bugfixes.
This commit is contained in:
parent
62e9af7ce6
commit
1a4194f176
1 changed files with 29 additions and 0 deletions
29
Functions/Misc/getjobs
Normal file
29
Functions/Misc/getjobs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Call this from the preexec function like so:
|
||||
# preexec() {
|
||||
# getjobs "${(z)1}"
|
||||
# }
|
||||
setopt localoptions noshwordsplit noksharrays
|
||||
local texts
|
||||
case $1 in
|
||||
fg|bg) shift; [[ -n $1 ]] || set -- %% ;;
|
||||
%*) ;;
|
||||
*) return 0 ;;
|
||||
esac
|
||||
repeat $#
|
||||
do
|
||||
# This case statement emulates jobs.c:getjob()
|
||||
case $1 in
|
||||
[\;\&\|]|\|\||\&\&) break ;;
|
||||
%(|[%+])) 1=${(k)jobstates[(r)*:+:*]} ;;
|
||||
%-) 1=${(k)jobstates[(r)*:-:*]} ;;
|
||||
%<->) 1=${1#%} ;;
|
||||
%[?]*) 1=${${(Ok)jobtexts[(R)*${1#%[?]}*]}[1]} ;;
|
||||
*) 1=${${(Ok)jobtexts[(R)$1*]}[1]} ;;
|
||||
esac
|
||||
[[ -n $1 ]] && texts=($texts ${jobtexts[$1]})
|
||||
shift
|
||||
done
|
||||
# Remove the "-s" below if you'd prefer that this just report
|
||||
# what jobs are being affected rather than modify the history
|
||||
(( $#texts )) && print -s ${(j:; :)texts} "$*"
|
||||
return 0
|
||||
Loading…
Add table
Add a link
Reference in a new issue