The following commit has been merged in the master branch:
commit 95cd673b5cbd5658cbf56a56a4113722aab92177
Author: Ville Skyttä <[email protected]>
Date:   Tue Apr 14 21:24:20 2009 +0300

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

diff --git a/CHANGES b/CHANGES
index f5db787..84d31d7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -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 <[email protected]>  Wed, 25 Mar 2009 23:18:24 +0100
 
 bash-completion (1.0)
diff --git a/bash_completion b/bash_completion
index dfcf518..3ec3f0d 100644
--- a/bash_completion
+++ b/bash_completion
@@ -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

-- 
bash-completion

_______________________________________________
Bash-completion-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/bash-completion-commits

Reply via email to