mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-26 18:01:03 +02:00
40344: new lsblk completion
This commit is contained in:
parent
00f16c8e68
commit
cfc8165bc1
2 changed files with 61 additions and 0 deletions
|
@ -1,3 +1,7 @@
|
|||
2017-01-12 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 40344: Completion/Linux/Command/_lsblk: new lsblk completion
|
||||
|
||||
2017-01-12 Peter Stephenson <p.w.stephenson@ntlworld.com>
|
||||
|
||||
* unposted: Src/hashtable.c: one missing *name = NULL.
|
||||
|
|
57
Completion/Linux/Command/_lsblk
Normal file
57
Completion/Linux/Command/_lsblk
Normal file
|
@ -0,0 +1,57 @@
|
|||
#compdef lsblk
|
||||
|
||||
local sep ret=1
|
||||
local -a values dedup suf=( -qS , )
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
||||
_arguments -C -s -S \
|
||||
'(H -a --all)'{-a,--all}'[print all devices]' \
|
||||
'(H -b --bytes)'{-b,--bytes}'[print size in bytes rather than in human readable format]' \
|
||||
'(H -d --nodeps)'{-d,--nodeps}"[don't print slaves or holders]" \
|
||||
'(H -I --include)*'{-e,--exclude}'[exclude devices by major number]:major device number:->majorlist' \
|
||||
'(H -e --exclude)*'{-I+,--include=}'[show only devices with specified major numbers]:major device number:->majorlist' \
|
||||
'(H -n --noheadings)'{-n,--noheadings}"[don't print headings]" \
|
||||
'(H -p --paths)'{-p,--paths}'[print complete device path]' \
|
||||
'(H -s --inverse)'{-s,--inverse}'[reverse dependency order]' \
|
||||
'(H -x --sort)'{-x+,--sort=}'[sort output by specified column]:column:->columns' \
|
||||
'*:device:_files -g "*(-%b)" -P / -W /' \
|
||||
+ fields \
|
||||
'(H -D --discard -o --output -O --output-all)'{-D,--discard}'[output discard capabilities]' \
|
||||
'(H -f --fs -o --output -O --output-all)'{-f,--fs}'[output info about filesystems]' \
|
||||
'(H -m --perms -o --output -O --output-all)'{-m,--perms}'[output info about permissions]' \
|
||||
'(H -S --scsi -o --output -O --output-all)'{-S,--scsi}'[output info about SCSI devices]' \
|
||||
'(H -t --topology -o --output -O --output-all)'{-t,--topology}'[output info about topology]' \
|
||||
'(H fields)'{-o+,--output=}'[specify output columns]:output column:->columnlist' \
|
||||
'(H fields)'{-O,--output-all}'[output all columns]' \
|
||||
+ '(format)' \
|
||||
'(H)'{-i,--ascii}'[output ascii characters only]' \
|
||||
'(H)'{-J,--json}'[use JSON output format]' \
|
||||
'(H)'{-l,--list}'[use list format output]' \
|
||||
'(H)'{-P,--pairs}'[use key="value" output format]' \
|
||||
'(H)'{-r,--raw}'[use raw output format]' \
|
||||
+ 'H' \
|
||||
'(* -)'{-h,--help}'[display help information]' \
|
||||
'(* -)'{-V,--version}'[display version information]' && ret=0
|
||||
|
||||
case $state in
|
||||
*list)
|
||||
dedup=( ${(Ms.,.)PREFIX##*,} ${(Ms.,.)SUFFIX%%,*} )
|
||||
compset -S ',*' && suf=()
|
||||
compset -P '*,'
|
||||
;|
|
||||
column*)
|
||||
values=(
|
||||
${${${${(f)"$(_call_program columns lsblk -h)"}[(r)Available*,-3]## #}[2,-1]//:/\\:}/ /:}
|
||||
)
|
||||
_describe -t fields column values -M 'm:{a-z}={A-Z}' $suf -F dedup && ret=0
|
||||
;;
|
||||
major*)
|
||||
zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
|
||||
values=( ${${${(f)"$(</proc/devices)"}[(r)Block*,-1]## #}[2,-1]/ /:} )
|
||||
zformat -a values " $sep " $values
|
||||
_wanted -V devices expl 'major device number' compadd $suf -d values -F dedup ${values%% *} && ret=0
|
||||
;;
|
||||
esac
|
||||
|
||||
return ret
|
Loading…
Reference in a new issue