]> git.ipfire.org Git - thirdparty/util-linux.git/blame - bash-completion/lsblk
Merge branch 'lsclocks/relative-time' of https://github.com/t-8ch/util-linux
[thirdparty/util-linux.git] / bash-completion / lsblk
CommitLineData
76dceb10
SK
1_lsblk_module()
2{
c6b1d511 3 local cur prev OPTS LSBLK_COLS_ALL
76dceb10
SK
4 COMPREPLY=()
5 cur="${COMP_WORDS[COMP_CWORD]}"
6 prev="${COMP_WORDS[COMP_CWORD-1]}"
b8446f75 7
c6b1d511 8 LSBLK_COLS_ALL="
a83bea2d
KZ
9 NAME KNAME PATH MAJ:MIN FSAVAIL FSSIZE FSTYPE FSUSED FSUSE% FSVER MOUNTPOINT
10 LABEL UUID PTUUID PTTYPE PARTTYPE PARTTYPENAME PARTLABEL PARTUUID PARTFLAGS RA
11 RO RM HOTPLUG MODEL SERIAL SIZE STATE OWNER GROUP MODE ALIGNMENT MIN-IO OPT-IO
12 PHY-SEC LOG-SEC ROTA SCHED RQ-SIZE TYPE DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
ca5f4bd0 13 WSAME WWN RAND PKNAME HCTL TRAN SUBSYSTEMS REV VENDOR ZONED ZONE-SZ ZONE-WGRAN
3b262733 14 ZONE-APP ZONE-NR ZONE-OMAX ZONE-AMAX DAX MQ
c6b1d511 15 "
b8446f75 16
76dceb10
SK
17 case $prev in
18 '-e'|'--exclude'|'-I'|'--include')
b5b80e5a
BE
19 local realcur prefix MAJOR_ALL MAJOR I J
20 realcur="${cur##*,}"
21 prefix="${cur%$realcur}"
76dceb10
SK
22 for I in /sys/dev/block/*; do
23 J=${I##*/}
c6f0bdfe 24 MAJOR_ALL="${MAJOR_ALL:-""} ${J%%:*}"
b5b80e5a 25 done
c6f0bdfe 26 for WORD in ${MAJOR_ALL:-""}; do
b5b80e5a 27 if ! [[ $prefix == *"$WORD"* ]]; then
c6f0bdfe 28 MAJOR="$WORD ${MAJOR:-""}"
b5b80e5a 29 fi
76dceb10 30 done
76dceb10 31 compopt -o nospace
c6f0bdfe 32 COMPREPLY=( $(compgen -P "$prefix" -W "${MAJOR:-""}" -S ',' -- $realcur) )
76dceb10
SK
33 return 0
34 ;;
ca59e01e 35 '-o'|'--output'|'-E'|'--dedup')
b5b80e5a
BE
36 local prefix realcur LSBLK_COLS
37 realcur="${cur##*,}"
38 prefix="${cur%$realcur}"
39 for WORD in $LSBLK_COLS_ALL; do
40 if ! [[ $prefix == *"$WORD"* ]]; then
c6f0bdfe 41 LSBLK_COLS="$WORD ${LSBLK_COLS:-""}"
b5b80e5a
BE
42 fi
43 done
76dceb10 44 compopt -o nospace
b5b80e5a 45 COMPREPLY=( $(compgen -P "$prefix" -W "$LSBLK_COLS" -S ',' -- $realcur) )
b8446f75
KZ
46 return 0
47 ;;
48 '-x'|'--sort')
49 compopt -o nospace
b5b80e5a 50 COMPREPLY=( $(compgen -W "$LSBLK_COLS_ALL" -- $cur) )
76dceb10
SK
51 return 0
52 ;;
d4f9b8d7
VS
53 '-h'|'--help'|'-V'|'--version')
54 return 0
55 ;;
76dceb10
SK
56 esac
57 case $cur in
58 -*)
0d5b9b8a
VS
59 OPTS="--all
60 --bytes
61 --nodeps
62 --discard
63 --exclude
64 --fs
65 --help
66 --include
c6b1d511 67 --json
0d5b9b8a
VS
68 --ascii
69 --list
ba5e7b7e
SK
70 --dedup
71 --merge
0d5b9b8a
VS
72 --perms
73 --noheadings
74 --output
c6b1d511
SK
75 --output-all
76 --paths
0d5b9b8a
VS
77 --pairs
78 --raw
79 --inverse
80 --topology
81 --scsi
97afabf7 82 --nvme
1b3e8f5d 83 --virtio
b8446f75 84 --sort
7636d906 85 --width
0d5b9b8a
VS
86 --help
87 --version"
76dceb10
SK
88 COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
89 return 0
90 ;;
91 esac
0c8865f8 92 compopt -o bashdefault -o default
396a6d7d 93 COMPREPLY=( $(compgen -W "$($1 -pnro name)" -- $cur) )
76dceb10
SK
94 return 0
95}
96complete -F _lsblk_module lsblk