2012-06-16 08:30:10 +08:00
|
|
|
function __fish_complete_lpr_option --description 'Complete lpr option'
|
2024-12-16 00:27:00 +08:00
|
|
|
set -l optstr "$(commandline -t)"
|
2016-11-28 13:27:22 +08:00
|
|
|
switch $optstr
|
|
|
|
case '*=*'
|
2017-07-25 11:45:43 +08:00
|
|
|
string split -m1 = -- "$optstr" | read -l opt val
|
2016-11-28 13:27:22 +08:00
|
|
|
set -l descr
|
2018-04-02 04:42:38 +08:00
|
|
|
for l in (lpoptions -l 2>/dev/null | string match -- "*$opt*" | string replace -r '.*/(.*):\s*(.*)$' '$1 $2' | string split " ")
|
2016-11-28 13:27:22 +08:00
|
|
|
if not set -q descr[1]
|
|
|
|
set descr $l
|
|
|
|
continue
|
|
|
|
end
|
|
|
|
set -l default ''
|
|
|
|
if string match -q '\**' -- $l
|
|
|
|
set default 'Default '
|
|
|
|
set l (string sub -s 2 -- $l)
|
|
|
|
end
|
|
|
|
echo $opt=$l\t$default$descr
|
|
|
|
end
|
|
|
|
case '*'
|
2018-04-02 04:42:38 +08:00
|
|
|
lpoptions -l 2>/dev/null | string replace -r '(.*)/(.*):.*$' '$1=\t$2'
|
2016-11-28 13:27:22 +08:00
|
|
|
end
|
2012-06-16 08:30:10 +08:00
|
|
|
|
|
|
|
end
|