1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-11-20 14:04:03 +01:00
zsh/Completion/User/_lp

53 lines
1.3 KiB
Plaintext
Raw Normal View History

2000-01-05 15:14:46 +01:00
#compdef lp lpr lpq lprm
2000-04-01 22:43:43 +02:00
local expl ret=1 printer list disp strs shown
2000-01-05 15:14:46 +01:00
if compset -P -P || [[ "$words[CURRENT-1]" = -P ]]; then
_printers
2000-01-05 15:14:46 +01:00
else
if [[ "$service" = (lpq|lprm) ]]; then
2000-04-01 22:43:43 +02:00
if [[ "$words" = *-P* ]]; then
printer=(-P "${${words##*-P( |)}%% *}")
else
printer=()
fi
list=( ${(M)"${(f@)$(_call jobs lpq $printer 2> /dev/null)}":#[0-9]*} )
2000-01-05 15:14:46 +01:00
if (( $#list )); then
_tags users jobs
while _tags; do
2000-04-01 22:43:43 +02:00
if _requested users; then
2000-01-05 15:14:46 +01:00
strs=( "${(@)${(@)list##[^ ]##[ ]##[^ ]##[ ]##}%%[ ]*}" )
if [[ -z "$shown" ]] &&
2000-04-01 22:43:43 +02:00
zstyle -T ":completion:${curcontext}:users" verbose; then
2000-01-05 15:14:46 +01:00
disp=(-ld list)
shown=yes
else
disp=()
fi
2000-05-31 11:38:25 +02:00
_all_labels users expl user compadd "$disp[@]" -a strs ||
2000-04-01 22:43:43 +02:00
_users && ret=0
2000-01-05 15:14:46 +01:00
fi
2000-04-01 22:43:43 +02:00
if _requested jobs; then
2000-01-05 15:14:46 +01:00
strs=( "${(@)${(@)list##[^ ]##[ ]##[^ ]##[ ]##[^ ]##[ ]##}%%[ ]*}" )
if [[ -z "$shown" ]] &&
2000-04-01 22:43:43 +02:00
zstyle -T ":completion:${curcontext}:jobs" verbose; then
2000-01-05 15:14:46 +01:00
disp=(-ld list)
shown=yes
else
disp=()
fi
2000-05-31 11:38:25 +02:00
_all_labels jobs expl job compadd "$disp[@]" -a strs && ret=0
2000-01-05 15:14:46 +01:00
fi
(( ret )) || return 0
done
else
_message 'no print jobs'
fi
return 1
else
_ps
fi
fi