--- /dev/null
+_addpart_module()
+{
+ local cur prev
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ case $COMP_CWORD in
+ 1)
+ local DEVS=''
+ while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ OPTS="-h --help -V --version $DEVS"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ ;;
+ 2)
+ # FIXME: how to determine next free partition number
+ ;;
+ 3)
+ COMPREPLY=( $(compgen -W "start" -- $cur) )
+ ;;
+ 4)
+ COMPREPLY=( $(compgen -W "length" -- $cur) )
+ ;;
+ esac
+ return 0
+}
+complete -F _addpart_module addpart
--- /dev/null
+_blockdev_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ OPTS="-h -V -q
+ --report
+ --getsz
+ --setro
+ --setrw
+ --getro
+ --getdiscardzeroes
+ --getss
+ --getpbsz
+ --getiomin
+ --getioopt
+ --getalignoff
+ --getmaxsect
+ --getbsz
+ --setbsz
+ --getsize64
+ --setra
+ --getra
+ --setfra
+ --getfra
+ --flushbufs
+ --rereadpt
+ $DEVS"
+ case $prev in
+ '--setbsz')
+ COMPREPLY=( $(compgen -W "bytes" -- $cur) )
+ return 0
+ ;;
+ '--setbsz'|'--setfra')
+ COMPREPLY=( $(compgen -W "sectors" -- $cur) )
+ return 0
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+}
+complete -F _blockdev_module blockdev
--- /dev/null
+_delpart_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $COMP_CWORD in
+ 1)
+ local DEV TYPE DEVICES=''
+ while read DEV TYPE; do
+ [ $TYPE = 'disk' ] && DEVICES+="$DEV "
+ done < <(lsblk -pnro name,type)
+ OPTS="-h --help -V --version $DEVICES"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ ;;
+ 2)
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) )
+ ;;
+ esac
+ return 0
+}
+complete -F _delpart_module delpart
--- /dev/null
+_fdformat_module()
+{
+ local cur OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ DEVS=$(for I in echo /dev/fd*; do if [ -e $I ]; then echo $I; fi; done)
+ OPTS="-n --no-verify -h --help -V --version $DEVS"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+}
+complete -F _fdformat_module fdformat
--- /dev/null
+_fsck_module()
+{
+ local cur prev OPTS DEVS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-b')
+ COMPREPLY=( $(compgen -W "superblock" -- $cur) )
+ return 0
+ ;;
+ '-B')
+ COMPREPLY=( $(compgen -W "blocksize" -- $cur) )
+ return 0
+ ;;
+ '-j')
+ COMPREPLY=( $(compgen -W "external_journal" -- $cur) )
+ return 0
+ ;;
+ '-l'|'-L')
+ COMPREPLY=( $(compgen -W "bad_blocks_file" -- $cur) )
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS="-p -n -y -c -f -v -b -B -j -l -L"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+ return 0
+}
+complete -F _fsck_module fsck
--- /dev/null
+_fsck.cramfs_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ OPTS='-v --verbose -x --destination -h --help -V --version file'
+ case $prev in
+ '-x'|'--destination')
+ compopt -o filenames
+ COMPREPLY=( $(compgen -o dirnames -- ${cur:-"/"}) )
+ return 0
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -S ' ' -- $cur) )
+ return 0
+}
+complete -F _fsck.cramfs_module fsck.cramfs
--- /dev/null
+_fsck.minix_module()
+{
+ local cur OPTS DEVS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ OPTS="-l -a -r -v -s -m -f -V --version"
+ COMPREPLY=( $(compgen -W "${OPTS[*]} $DEVS" -- $cur) )
+ return 0
+}
+complete -F _fsck.minix_module fsck.minix
--- /dev/null
+_isosize_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ OPTS='-d --divisor -x --sectors -h --help -V --version'
+ case $prev in
+ '-d'|'--divisor')
+ COMPREPLY=( $(compgen -W "number" -- $cur) )
+ return 0
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+}
+complete -F _isosize_module isosize
--- /dev/null
+_mkfs_module()
+{
+ local cur prev OPTS DEVS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-t'|'--type')
+ FSTYPES=$(for I in /sbin/mkfs.* /usr/sbin/mkfs.*; do if [ -e $I ]; then echo ${I##*mkfs.}; fi; done)
+ COMPREPLY=( $(compgen -W "$FSTYPES" -- $cur) )
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS='-t --type --verbose -h --help -V --version'
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
+ return 0
+}
+complete -F _mkfs_module mkfs
--- /dev/null
+_bfs_module()
+{
+ local cur prev OPTS DEVS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-N'|'--inodes')
+ COMPREPLY=( $(compgen -W "number" -- $cur) )
+ return 0
+ ;;
+ '-V'|'--vname'|'-F'|'--fname')
+ COMPREPLY=( $(compgen -W "name" -- $cur) )
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS='-N --inodes --vname --fname -v --verbose -h --help -V --version'
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ COMPREPLY=( $(compgen -W "$DEVS /path/to/file" -- $cur) )
+ return 0
+}
+complete -F _bfs_module bfs
--- /dev/null
+_mkfs.cramfs_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-b')
+ COMPREPLY=( $(compgen -W "blksize" -- $cur) )
+ return 0
+ ;;
+ '-e')
+ COMPREPLY=( $(compgen -W "edition" -- $cur) )
+ return 0
+ ;;
+ '-N')
+ COMPREPLY=( $(compgen -W "big little host" -- $cur) )
+ return 0
+ ;;
+ '-i')
+ COMPREPLY=( $(compgen -f -- $cur) )
+ return 0
+ ;;
+ '-n')
+ COMPREPLY=( $(compgen -W "name" -- $cur) )
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS="-h -v -E -b -e -N -i -n -p -s -z"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ compopt -o filenames
+ COMPREPLY=( $(compgen -f -- $cur) )
+ return 0
+}
+complete -F _mkfs.cramfs_module mkfs.cramfs
--- /dev/null
+_mkfs.minix_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-i')
+ COMPREPLY=( $(compgen -W "inodes" -- $cur) )
+ return 0
+ ;;
+ '-l')
+ COMPREPLY=( $(compgen -W "badblocks-file" -- $cur) )
+ return 0
+ ;;
+ '-n')
+ COMPREPLY=( $(compgen -W "14 30" -- $cur) )
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS="-c -i -l -n -1 -2 -3"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ local DEVS
+ while read dev; do DEVS+="$dev " ; done < <(lsblk -pnro name)
+ COMPREPLY=( $(compgen -W "$DEVS" -- $cur) )
+ return 0
+}
+complete -F _mkfs.minix_module mkfs.minix
--- /dev/null
+_mkswap_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-p'|'--pagesize')
+ COMPREPLY=( $(compgen -W "bytes" -- $cur) )
+ return 0
+ ;;
+ '-L'|'--label')
+ COMPREPLY=( $(compgen -W "label" -- $cur) )
+ return 0
+ ;;
+ '-v'|'--swapversion')
+ COMPREPLY=( $(compgen -W "1" -- $cur) )
+ return 0
+ ;;
+ '-U'|--uuid)
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS="-c --check -f --force -p --pagesize -L --label -v --swapversion -U --uuid -V --version -h --help"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ compopt -o filenames
+ COMPREPLY=( $(compgen -f -- $cur) )
+ return 0
+}
+complete -F _mkswap_module mkswap
--- /dev/null
+_partx_module()
+{
+ local cur prev OPTS OUTPUT
+ COMPREPLY=()
+ OUTPUT="NR START END SECTORS SIZE NAME UUID TYPE FLAGS SCHEME"
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-n'|'--nr')
+ return 0
+ ;;
+ '-o'|'--output')
+ # FIXME: how to append to a string with compgen?
+ compopt -o nospace
+ COMPREPLY=( $(compgen -W "$OUTPUT" -S ',' -- $cur) )
+ return 0
+ ;;
+ '-t'|'--type')
+ # FIXME: some command should list type libblkid knows.
+ COMPREPLY=( $(compgen -W "aix bsd dos gpt mac minix sgi solaris_x86 sun ultrix unixware" -- $cur) )
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS="-a --add -d --delete -s --show -u --update -b --bytes -g --noheadings -n --nr -o --output -P --pairs -r --raw -t --type -v --verbose -h --help -V --version"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ local DEV TYPE DEVICES=''
+ while read DEV TYPE; do
+ [ $TYPE = 'disk' ] && DEVICES+="$DEV "
+ done < <(lsblk -pnro name,type)
+ COMPREPLY=( $(compgen -W "$DEVICES" -- $cur) )
+ return 0
+}
+complete -F _partx_module partx
--- /dev/null
+_raw_module()
+{
+ local cur
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ case $cur in
+ -*)
+ local OPTS
+ OPTS="-q --query -a --all -h --help -V --version"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ COMPREPLY=( $(compgen -W "$(for I in /dev/raw/*; do if [ -e $I ]; then echo $I; fi; done)" -- $cur) )
+ return 0
+}
+complete -F _raw_module raw
--- /dev/null
+_resizepart_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ case $COMP_CWORD in
+ 1)
+ local DEV TYPE DEVICES=''
+ while read DEV TYPE; do
+ [ $TYPE = 'disk' ] && DEVICES+="$DEV "
+ done < <(lsblk -pnro name,type)
+ OPTS="-h --help -V --version $DEVICES"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ ;;
+ 2)
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ COMPREPLY=( $(compgen -W "$(cat /sys/block/${prev##*/}/*/partition 2>/dev/null)" -- $cur) )
+ ;;
+ 3)
+ COMPREPLY="length"
+ ;;
+ esac
+ return 0
+}
+complete -F _resizepart_module resizepart
--- /dev/null
+_swaplabel_module()
+{
+ local cur prev OPTS
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ case $prev in
+ '-L'|'--label')
+ COMPREPLY=( $(compgen -W "label" -- $cur) )
+ return 0
+ ;;
+ '-U'|'--uuid')
+ COMPREPLY=( $(compgen -W '$(uuidgen)' -- $cur) )
+ return 0
+ ;;
+ esac
+ case $cur in
+ -*)
+ OPTS="-L --label -U --uuid -h --help -V --version"
+ COMPREPLY=( $(compgen -W "${OPTS[*]}" -- $cur) )
+ return 0
+ ;;
+ esac
+ compopt -o filenames
+ COMPREPLY=( $(compgen -f -- $cur) )
+ return 0
+}
+complete -F _swaplabel_module swaplabel