about summary refs log tree commit diff
path: root/Completion/Base/_jobs
blob: 869aeeb8a48746b0445601e7a593319ff8bc2622 (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
#autoload

local expl disp jobs job jids

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
  disp=( "$disp[@]" "${(l:3:: ::%:)job} -- ${jobtexts[$job]}" )
  jobs=( "$jobs[@]" "$job" )
done

compadd "$@" "$expl[@]" -ld disp - "%$^jobs[@]"