]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
bash-completion: disk-utils
authorSami Kerola <kerolasa@iki.fi>
Fri, 22 Mar 2013 23:37:11 +0000 (23:37 +0000)
committerSami Kerola <kerolasa@iki.fi>
Mon, 1 Apr 2013 15:08:02 +0000 (16:08 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
17 files changed:
shell-completion/addpart [new file with mode: 0644]
shell-completion/blockdev [new file with mode: 0644]
shell-completion/delpart [new file with mode: 0644]
shell-completion/fdformat [new file with mode: 0644]
shell-completion/fsck [new file with mode: 0644]
shell-completion/fsck.cramfs [new file with mode: 0644]
shell-completion/fsck.minix [new file with mode: 0644]
shell-completion/isosize [new file with mode: 0644]
shell-completion/mkfs [new file with mode: 0644]
shell-completion/mkfs.bfs [new file with mode: 0644]
shell-completion/mkfs.cramfs [new file with mode: 0644]
shell-completion/mkfs.minix [new file with mode: 0644]
shell-completion/mkswap [new file with mode: 0644]
shell-completion/partx [new file with mode: 0644]
shell-completion/raw [new file with mode: 0644]
shell-completion/resizepart [new file with mode: 0644]
shell-completion/swaplabel [new file with mode: 0644]

diff --git a/shell-completion/addpart b/shell-completion/addpart
new file mode 100644 (file)
index 0000000..b6f119a
--- /dev/null
@@ -0,0 +1,25 @@
+_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
diff --git a/shell-completion/blockdev b/shell-completion/blockdev
new file mode 100644 (file)
index 0000000..ce986cb
--- /dev/null
@@ -0,0 +1,44 @@
+_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
diff --git a/shell-completion/delpart b/shell-completion/delpart
new file mode 100644 (file)
index 0000000..e3ee406
--- /dev/null
@@ -0,0 +1,23 @@
+_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
diff --git a/shell-completion/fdformat b/shell-completion/fdformat
new file mode 100644 (file)
index 0000000..4ad1c3d
--- /dev/null
@@ -0,0 +1,11 @@
+_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
diff --git a/shell-completion/fsck b/shell-completion/fsck
new file mode 100644 (file)
index 0000000..40b9a13
--- /dev/null
@@ -0,0 +1,36 @@
+_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
diff --git a/shell-completion/fsck.cramfs b/shell-completion/fsck.cramfs
new file mode 100644 (file)
index 0000000..410b084
--- /dev/null
@@ -0,0 +1,18 @@
+_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
diff --git a/shell-completion/fsck.minix b/shell-completion/fsck.minix
new file mode 100644 (file)
index 0000000..6239ae4
--- /dev/null
@@ -0,0 +1,11 @@
+_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
diff --git a/shell-completion/isosize b/shell-completion/isosize
new file mode 100644 (file)
index 0000000..2b4a499
--- /dev/null
@@ -0,0 +1,17 @@
+_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
diff --git a/shell-completion/mkfs b/shell-completion/mkfs
new file mode 100644 (file)
index 0000000..1947119
--- /dev/null
@@ -0,0 +1,25 @@
+_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
diff --git a/shell-completion/mkfs.bfs b/shell-completion/mkfs.bfs
new file mode 100644 (file)
index 0000000..7a47a76
--- /dev/null
@@ -0,0 +1,28 @@
+_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
diff --git a/shell-completion/mkfs.cramfs b/shell-completion/mkfs.cramfs
new file mode 100644 (file)
index 0000000..65ee988
--- /dev/null
@@ -0,0 +1,40 @@
+_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
diff --git a/shell-completion/mkfs.minix b/shell-completion/mkfs.minix
new file mode 100644 (file)
index 0000000..085a058
--- /dev/null
@@ -0,0 +1,33 @@
+_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
diff --git a/shell-completion/mkswap b/shell-completion/mkswap
new file mode 100644 (file)
index 0000000..30d517c
--- /dev/null
@@ -0,0 +1,35 @@
+_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
diff --git a/shell-completion/partx b/shell-completion/partx
new file mode 100644 (file)
index 0000000..db2eded
--- /dev/null
@@ -0,0 +1,38 @@
+_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
diff --git a/shell-completion/raw b/shell-completion/raw
new file mode 100644 (file)
index 0000000..27f0354
--- /dev/null
@@ -0,0 +1,17 @@
+_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
diff --git a/shell-completion/resizepart b/shell-completion/resizepart
new file mode 100644 (file)
index 0000000..b178b52
--- /dev/null
@@ -0,0 +1,25 @@
+_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
diff --git a/shell-completion/swaplabel b/shell-completion/swaplabel
new file mode 100644 (file)
index 0000000..c857d15
--- /dev/null
@@ -0,0 +1,28 @@
+_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