mirror of
https://github.com/zsh-users/zsh-completions.git
synced 2026-11-24 18:14:19 +08:00
55 lines
2.4 KiB
Plaintext
55 lines
2.4 KiB
Plaintext
#compdef lsblk
|
|
|
|
local arguments
|
|
|
|
local lsblk_cols_all=(
|
|
NAME KNAME MAJ:MIN FSTYPE MOUNTPOINT
|
|
LABEL UUID PARTTYPE PARTLABEL PARTUUID PARTFLAGS
|
|
RA RO RM
|
|
MODEL SIZE STATE OWNER GROUP MODE
|
|
ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC
|
|
ROTA SCHED RQ-SIZE TYPE DISC-ALN
|
|
DISC-GRAN DISC-MAX DISC-ZERO WSAME WWN
|
|
RAND PKNAME HCTL TRAN REV VENDOR)
|
|
|
|
_lsblk_columns() {
|
|
compadd $@ $lsblk_cols_all
|
|
}
|
|
|
|
_lsblk_major_number() {
|
|
# /sys/dev/block/ contains MAJOR:MINOR symlinks. eg. 7:0
|
|
local device_paths=(/sys/dev/block/*(N))
|
|
local major_numbers=(${${device_paths##*/}%%:*})
|
|
# major_numbers might have duplicates but compadd handles that
|
|
compadd $@ $major_numbers
|
|
}
|
|
|
|
arguments=(
|
|
'(-a --all)'{-a,--all}'[print all devices]'
|
|
'(-b --bytes)'{-b,--bytes}'[print size in bytes rather than in human readable format]'
|
|
'(-d --nodeps)'{-d,--nodeps}'[dont print slaves or holders]'
|
|
'(-D --discard)'{-D,--discard}'[print discard capabilities]'
|
|
'(-e --exclude)'{-e,--exclude}'[exclude devices by major number (default: RAM disks)]:major number:_sequence _lsblk_major_number'
|
|
'(-f --fs)'{-f,--fs}'[output info about filesystems]'
|
|
'(-i --ascii)'{-i,--ascii}'[use ascii characters only]'
|
|
'(-I --include)'{-I,--include}'=[show only devices with specified major numbers]:major number:_sequence _lsblk_major_number'
|
|
'(-J --json)'{-J,--json}'[use JSON output format]'
|
|
'(-l --list)'{-l,--list}'[use list format output]'
|
|
'(-m --perms)'{-m,--perms}'[output info about permissions]'
|
|
'(-n --noheadings)'{-n,--noheadings}'[dont print headings]'
|
|
'(-o --output)'{-o,--output}'=[specify output columns]:Output columns:_sequence _lsblk_columns'
|
|
'(-O --output-all)'{-O,--output-all}'[output all columns]'
|
|
'(-p --paths)'{-p,--paths}'[print complete device path]'
|
|
'(-P --pairs)'{-P,--pairs}'[use key="value" output format]'
|
|
'(-r --raw)'{-r,--raw}'[use raw output format]'
|
|
'(-s --inverse)'{-s,--inverse}'[inverse dependencies]'
|
|
'(-S --scsi)'{-S,--scsi}'[output info about SCSI devices]'
|
|
'(-t --topology)'{-t,--topology}'[output info about topology]'
|
|
'(-x --sort)'{-x,--sort}'=[sort output by specified column]:Sort column:_lsblk_columns'
|
|
'(-h --help)'{-h,--help}'[display this help and exit]'
|
|
'(-V --version)'{-V,--version}'[output version information and exit]'
|
|
'*:device:_path_files -g "*(N-%) *(N-/)"'
|
|
)
|
|
|
|
_arguments -s $arguments
|