about summary refs log tree commit diff
path: root/Completion/Base/_job
blob: 081956c5177aa4dc03e972cf1a9c7ced5ac38d3b (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
#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:2:: :)job}] ${jobtexts[$job]}" )
  jobs=( "$jobs[@]" "$job" )
done

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