blob: ba83d784e50a365f01ddfb6b86438f92ceacf131 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#autoload
local expl disp jobs job jids pfx='%' desc
_tags any jobs || return 1
_style jobs prefix-needed yes && [[ "$PREFIX" != %* ]] && return 1
_style jobs prefix-hidden yes && pfx=''
_style jobs description yes && desc=yes
if [[ "$1" = -r ]]; then
jids=( "${(@k)jobstates[(R)running*]}" )
shift
_description expl 'running job'
elif [[ "$1" = -s ]]; then
jids=( "${(@k)jobstates[(R)running*]}" )
shift
_description expl 'suspended job'
else
[[ "$1" = - ]] && shift
jids=( "${(@k)jobtexts}" )
_description expl job
fi
disp=()
jobs=()
for job in "$jids[@]"; do
[[ -n "$desc" ]] &&
disp=( "$disp[@]" "${pfx}${(r:2:: :)job} -- ${(r:COLUMNS-8:: :)jobtexts[$job]}" )
jobs=( "$jobs[@]" "$job" )
done
if [[ -n "$desc" ]]; then
compadd "$@" "$expl[@]" -ld disp - "%$^jobs[@]"
else
compadd "$@" "$expl[@]" - "%$^jobs[@]"
fi
|