The following commit has been merged in the master branch:
commit d2aedc83e143e7d506c8c5340dac4a820cc50076
Author: Igor Murzov <[email protected]>
Date:   Mon Feb 6 19:09:51 2012 +0400

    su: Add linux-specific completion

diff --git a/bash_completion b/bash_completion
index a080b1c..de52e2f 100644
--- a/bash_completion
+++ b/bash_completion
@@ -59,7 +59,7 @@ complete -d pushd
 # start of section containing compspecs that can be handled within bash
 
 # user commands see only users
-complete -u su write chfn groups slay w sux runuser
+complete -u write chfn groups slay w sux runuser
 
 # bg completes with stopped jobs
 complete -A stopped -P '"%' -S '"' bg
diff --git a/completions/Makefile.am b/completions/Makefile.am
index c3efb27..507a6b7 100644
--- a/completions/Makefile.am
+++ b/completions/Makefile.am
@@ -293,6 +293,7 @@ bashcomp_DATA = a2x \
                sshmitm \
                sshow \
                strace \
+               su \
                sudo \
                svk \
                sync_members \
diff --git a/completions/su b/completions/su
new file mode 100644
index 0000000..df91230
--- /dev/null
+++ b/completions/su
@@ -0,0 +1,35 @@
+# bash completion for su(1)                                -*- shell-script -*-
+
+if [[ $OSTYPE != *linux* ]]; then
+    complete -u su # default completion
+    return
+fi
+
+_su() # linux-specific completion
+{
+    local cur prev words cword
+    _init_completion || return
+
+    case "$prev" in
+        -s|--shell)
+            _filedir
+            return
+            ;;
+        -c|--command)
+            local IFS=$'\n'
+            compopt -o filenames
+            COMPREPLY=( $( compgen -d -c -- "$cur" ) )
+            return
+            ;;
+    esac
+
+    if [[ "$cur" == -* ]]; then
+        COMPREPLY=( $( compgen -W '$( _parse_help "$1" --help )' -- "$cur" ) )
+        [[ $COMPREPLY == *= ]] && compopt -o nospace
+        return
+    fi
+
+    COMPREPLY=( $( compgen -u -- "$cur" ) )
+} && complete -F _su su
+
+# ex: ts=4 sw=4 et filetype=sh

-- 
bash-completion

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

Reply via email to