[Bash-completion-commits] [SCM] bash-completion branch, master, updated. 1.90-146-gd2aedc8
Igor Murzov
e-mail at date.by
Fri Feb 17 01:26:21 UTC 2012
The following commit has been merged in the master branch:
commit d2aedc83e143e7d506c8c5340dac4a820cc50076
Author: Igor Murzov <e-mail at date.by>
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
More information about the Bash-completion-commits
mailing list