haiku/data/etc/bash_completion.d/lvm

1095 lines
23 KiB
Bash

# bash completion for lvm
have lvm && {
_volumegroups()
{
COMPREPLY=( $(compgen -W "$( vgscan 2>/dev/null | \
sed -n -e 's|.*Found.*"\(.*\)".*$|\1|p' )" -- "$cur" ) )
}
_physicalvolumes()
{
COMPREPLY=( $(compgen -W "$( pvscan 2>/dev/null | \
sed -n -e 's|^.*PV \(.*\) VG.*$|\1|p' )" -- "$cur" ) )
}
_logicalvolumes()
{
COMPREPLY=( $(compgen -W "$( lvscan 2>/dev/null | \
sed -n -e "s|^.*'\(.*\)'.*$|\1|p" )" -- "$cur" ) )
}
_units()
{
COMPREPLY=( $( compgen -W 'h s b k m g t H K M G T' -- "$cur" ) )
}
_sizes()
{
COMPREPLY=( $( compgen -W 'k K m M g G t T' -- "$cur" ) )
}
_args()
{
args=0
if [[ "${COMP_WORDS[0]}" == lvm ]]; then
offset=2
else
offset=1
fi
for (( i=$offset; i < COMP_CWORD; i++ )); do
if [[ "${COMP_WORDS[i]}" != -* ]]; then
args=$(($args + 1))
fi
done
}
_lvmdiskscan()
{
local cur
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug --help \
--lvmpartition --verbose --version' -- "$cur" ) )
fi
}
complete -F _lvmdiskscan lvmdiskscan
_pvscan()
{
local cur
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug --exported --novolumegroup \
--help --ignorelockingfailure --partial --short --uuid \
--verbose --version' -- "$cur" ) )
fi
}
complete -F _pvscan pvscan
_pvs()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-o|-O|--options|--sort)
COMPREPLY=( $( compgen -W 'pv_fmt pv_uuid \
pv_size pv_free pv_used pv_name \
pv_attr pv_pe_count \
pv_pe_alloc_count' -- "$cur" ) )
return 0
;;
--units)
_units
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--aligned --all --debug \
--help --ignorelockingfailure --noheadings \
--nosuffix --options --sort --separator --unbuffered --units \
--verbose --version' -- "$cur" ) )
else
_physicalvolumes
fi
}
complete -F _pvs pvs
_pvdisplay()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
--units)
_units
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--colon --columns --units \
--verbose --debug --help --version' -- "$cur" ) )
else
_physicalvolumes
fi
}
complete -F _pvdisplay pvdisplay
_pvchange()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|-x|--autobackup|--allocatable)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--all --autobackup \
--debug --help --test --uuid \
--allocatable --verbose --addtag --deltag \
--version' -- "$cur" ) )
else
_physicalvolumes
fi
}
complete -F _pvchange pvchange
_pvcreate()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
--restorefile)
_filedir
return 0
;;
-M|--metadatatype)
COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) )
return 0
;;
--metadatacopies)
COMPREPLY=( $( compgen -W '0 1 2' -- "$cur" ) )
return 0
;;
--metadatasize|--setphysicalvolumesize)
_sizes
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--restorefile --debug \
--force --help --labelsector --metadatatype \
--metadatacopies --metadatasize \
--setphysicalvolumesize --test --uuid \
--verbose --yes --version' -- "$cur" ) )
else
_physicalvolumes
fi
}
complete -F _pvcreate pvcreate
_pvmove()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
-n|--name)
_logicalvolumes
return 0
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--abort --autobackup \
--background --debug --force --help --interval --test --verbose \
--version --name' -- "$cur" ) )
else
_physicalvolumes
fi
}
complete -F _pvmove pvmove
_pvremove()
{
local cur
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug --force \
--help --yes --test --verbose --version' -- "$cur" ) )
else
_physicalvolumes
fi
}
complete -F _pvremove pvremove
_vgscan()
{
local cur
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug --help \
--ignorelockingfailure --mknodes \
--partial --verbose --version' -- "$cur" ) )
fi
}
complete -F _vgscan vgscan
_vgs()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-o|-O|--options|--sort)
COMPREPLY=( $( compgen -W 'vg_fmt vg_uuid vg_name \
vg_attr vg_size vg_free vg_sysid \
vg_extent_size vg_extent_count vg_free_count \
max_lv max_pv pv_count lv_count snap_count \
vg_seqno' -- "$cur" ) )
return 0
;;
--units)
_units
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--aligned --debug \
--help --ignorelockingfailure --noheadings \
--nosuffix --options --sort --partial \
--separator --unbuffered --units \
--verbose --version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgs vgs
_vgdisplay()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
--units)
_units
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--colon --columns --units \
--partial --activevolumegroups --verbose \
--debug --help --version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgdisplay vgdisplay
_vgchange()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-a|-A|-x|--available|--autobackup|--resizeable)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --alloc \
--partial --debug --help --ignorelockingfailure \
--test --uuid --verbose --version \
--available --resizeable --logicalvolume \
--addtag --deltag' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgchange vgchange
_vgcreate()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
-M|--metadatatype)
COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) )
return 0
;;
-s|--physicalextentsize)
_sizes
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --addtag --alloc \
--debug --help --maxlogicalvolumes --metadatatype \
--maxphysicalvolumes --physicalextentsize --test \
--verbose --version' -- "$cur" ) )
else
_args
if [ $args -eq 0 ]; then
_volumegroups
else
_physicalvolumes
fi
fi
}
complete -F _vgcreate vgcreate
_vgremove()
{
local cur
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug --help --test \
--verbose --version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgremove vgremove
_vgrename()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --debug \
--help --test --verbose --version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgrename vgrename
_vgreduce()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--all --autobackup \
--debug --help --removemissing --test \
--verbose --version' -- "$cur" ) )
else
_args
if [ $args -eq 0 ]; then
_volumegroups
else
_physicalvolumes
fi
fi
}
complete -F _vgreduce vgreduce
_vgextend()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
-L|--size)
_sizes
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --debug \
--help --test --verbose --version' -- "$cur" ) )
else
_args
if [ $args -eq 0 ]; then
_volumegroups
else
_physicalvolumes
fi
fi
}
complete -F _vgextend vgextend
_vgport()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--all --debug \
--help --verbose --version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgport vgimport vgexport
_vgck()
{
local cur
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug \
--help --verbose --version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgck vgck
_vgconvert()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-M|--metadatatype)
COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) )
return 0
;;
--metadatacopies)
COMPREPLY=( $( compgen -W '0 1 2' -- "$cur" ) )
return 0
;;
--metadatasize)
_sizes
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug --help --labelsector \
--metadatatype --metadatacopies --metadatasize \
--test --verbose --version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgconvert vgconvert
_vgcfgbackup()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-f|--file)
_filedir
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug --file --help \
--ignorelockingfailure --partial --verbose \
--version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgcfgbackup vgcfgbackup
_vgcfgrestore()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-f|--file)
_filedir
return 0
;;
-M|--metadatatype)
COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) )
return 0
;;
-n|--name)
_volumegroups
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug --file --list \
--help --metadatatype --name --test \
--verbose --version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgcfgrestore vgcfgrestore
_vgmerge()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --debug --help \
--list --test --verbose --version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgmerge vgmerge
_vgsplit()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
-M|--metadatatype)
COMPREPLY=( $( compgen -W '1 2' -- "$cur" ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --debug \
--help --list --metadatatype --test \
--verbose --version' -- "$cur" ) )
else
_args
if [[ $args -eq 0 || $args -eq 1 ]]; then
_volumegroups
else
_physicalvolumes
fi
fi
}
complete -F _vgsplit vgsplit
_vgmknodes()
{
local cur
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--debug --help --verbose \
--version' -- "$cur" ) )
else
_volumegroups
fi
}
complete -F _vgmknodes vgmknodes
_lvscan()
{
local cur
COMPREPLY=()
_get_comp_words_by_ref cur
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--blockdevice --debug \
--help --ignorelockingfailure \
--partial --verbose --version' -- "$cur" ) )
fi
}
complete -F _lvscan lvscan
_lvs()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-o|-O|--options|--sort)
COMPREPLY=( $( compgen -W 'lv_uuid lv_name lv_attr lv_minor \
lv_size seg_count origin snap_percent segtype stripes \
stripesize chunksize seg_start seg_size' -- "$cur" ) )
return 0
;;
--units)
_units
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--aligned --debug --help \
--ignorelockingfailure --noheadings --nosuffix --options \
--sort --partial --segments --separator --unbuffered --units \
--verbose --version' -- "$cur" ) )
else
_logicalvolumes
fi
}
complete -F _lvs lvs
_lvdisplay()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
--units)
_units
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--colon --columns --units \
--partial --maps --verbose --debug --help --version' -- "$cur" ) )
else
_logicalvolumes
fi
}
complete -F _lvdisplay lvdisplay
_lvchange()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-a|-A|-C|-M|--available|--autobackup|--continguous|--persistent)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
-p|--permission)
COMPREPLY=( $( compgen -W 'r rw' -- "$cur" ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --available \
--addtag --alloc --contiguous --debug --deltag \
--force --help --ignorelockingfailure \
--persistent --major --minor --partial \
--permission --readahead --refresh --test \
--verbose --version' -- "$cur" ) )
else
_logicalvolumes
fi
}
complete -F _lvchange lvchange
_lvcreate()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|-C|-M|-Z|--autobackup|--continguous|--persistent|--zero)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
-L|--size)
_sizes
return 0
;;
-p|--permission)
COMPREPLY=( $( compgen -W 'r rw' -- "$cur" ) )
return 0
;;
-n|--name)
_logicalvolumes
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --addtag --alloc \
--contiguous --debug --help --stripes \
--stripesize --extents --size --persistent \
--major --minor --name --permission \
--readahead --test --type --verbose --zero \
--version' -- "$cur" ) )
else
_args
if [ $args -eq 0 ]; then
_volumegroups
else
_physicalvolumes
fi
fi
}
complete -F _lvcreate lvcreate
_lvremove()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --debug \
--force --help --test --verbose --version' -- "$cur" ) )
else
_logicalvolumes
fi
}
complete -F _lvremove lvremove
_lvrename()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --debug \
--help --test --verbose --version' -- "$cur" ) )
else
_logicalvolumes
fi
}
complete -F _lvrename lvrename
_lvreduce()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
-L|--size)
_sizes
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup \
--debug --force --help --extents \
--size --nofsck --resizefs --test --verbose --version' -- "$cur" ) )
else
_logicalvolumes
fi
}
complete -F _lvreduce lvreduce
_lvresize()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
-L|--size)
_sizes
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --alloc \
--debug --help --stripes --stripesize \
--extents --size --nofsck --resizefs \
--test --type --verbose --version' -- "$cur" ) )
else
_args
if [ $args -eq 0 ]; then
_logicalvolumes
else
_physicalvolumes
fi
fi
}
complete -F _lvresize lvresize
_lvextend()
{
local cur prev
COMPREPLY=()
_get_comp_words_by_ref cur prev
case $prev in
-A|--autobackup)
COMPREPLY=( $( compgen -W 'y n' -- "$cur" ) )
return 0
;;
-L|--size)
_sizes
return 0
;;
esac
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '--autobackup --alloc \
--debug --help --stripes --stripesize \
--extents --size --nofsck --resizefs \
--test --type --verbose --version' -- "$cur" ) )
else
_args
if [ $args -eq 0 ]; then
_logicalvolumes
else
_physicalvolumes
fi
fi
}
complete -F _lvextend lvextend
_lvm()
{
local cur
COMPREPLY=()
_get_comp_words_by_ref cur
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W 'dumpconfig help lvchange \
lvcreate lvdisplay lvextend lvmchange \
lvmdiskscan lvmsadc lvmsar lvreduce \
lvremove lvrename lvresize lvs lvscan \
pvchange pvcreate pvdata pvdisplay pvmove \
pvremove pvresize pvs pvscan vgcfgbackup \
vgcfgrestore vgchange vgck vgconvert \
vgcreate vgdisplay vgexport vgextend \
vgimport vgmerge vgmknodes vgreduce \
vgremove vgrename vgs vgscan vgsplit \
version' -- "$cur" ) )
else
case ${COMP_WORDS[1]} in
pvchange)
_pvchange
;;
pvcreate)
_pvcreate
;;
pvdisplay)
_pvdisplay
;;
pvmove)
_pvmove
;;
pvremove)
_pvremove
;;
pvresize)
_pvresize
;;
pvs)
_pvs
;;
pvscan)
_pvscan
;;
vgcfgbackup)
_vgcfgbackup
;;
vgcfgrestore)
_vgcfgrestore
;;
vgchange)
_vgchange
;;
vgck)
_vgck
;;
vgconvert)
_vgconvert
;;
vgcreate)
_vgcreate
;;
vgdisplay)
_vgdisplay
;;
vgexport)
_vgexport
;;
vgextend)
_vgextend
;;
vgimport)
_vgimport
;;
vgmerge)
_vgmerge
;;
vgmknodes)
_vgmknodes
;;
vgreduce)
_vgreduce
;;
vgremove)
_vgremove
;;
vgrename)
_vgrename
;;
vgs)
_vgs
;;
vgscan)
_vgscan
;;
vgsplit)
_vgsplit
;;
lvchange)
_lvchange
;;
lvcreate)
_lvcreate
;;
lvdisplay)
_lvdisplay
;;
lvextend)
_lvextend
;;
lvreduce)
_lvreduce
;;
lvremove)
_lvremove
;;
lvrename)
_lvrename
;;
lvresize)
_lvresize
;;
lvs)
_lvs
;;
lvscan)
_lvscan
;;
esac
fi
}
complete -F _lvm lvm
}
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh