Add mount -L and -U completion (Raphaël Droz).

This commit is contained in:
Ville Skyttä 2009-04-14 21:24:20 +03:00
parent 5c0e30473f
commit 95cd673b5c
2 changed files with 12 additions and 2 deletions

View File

@ -40,6 +40,9 @@ bash-completion (1.x)
[ Guillaume Rousse ]
* Split mkinitrd completion to contrib/mkinitrd, improve it.
[ Raphaël Droz ]
* Add mount -L and -U completion.
-- David Paleino <d.paleino@gmail.com> Wed, 25 Mar 2009 23:18:24 +0100
bash-completion (1.0)

View File

@ -855,11 +855,12 @@ complete -F _umount $dirnames umount
#
_mount()
{
local cur i sm host
local cur i sm host prev
COMPREPLY=()
cur=`_get_cword`
[[ "$cur" == \\ ]] && cur="/"
prev=${COMP_WORDS[COMP_CWORD-1]}
for i in {,/usr}/{,s}bin/showmount; do [ -x $i ] && sm=$i && break; done
@ -884,8 +885,14 @@ _mount()
| grep "^$cur" ) )
else
# probably Linux
COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' \
if [ $prev = -L ]; then
COMPREPLY=( $( compgen -W '$(sed -ne "s/^[[:space:]]*LABEL=\([^[:space:]]*\).*/\1/p" /etc/fstab )' -- $cur ) )
elif [ $prev = -U ]; then
COMPREPLY=( $( compgen -W '$(sed -ne "s/^[[:space:]]*UUID=\([^[:space:]]*\).*/\1/p" /etc/fstab )' -- $cur ) )
else
COMPREPLY=( $( awk '! /^[ \t]*#/ {if ($2 ~ /\//) print $2}' \
/etc/fstab | grep "^$cur" ) )
fi
fi
return 0