summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2014-08-23 12:37:58 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2014-08-23 12:37:58 -0700
commit4bab43d11d5ce60950e69e54ab5a677c15f13e0f (patch)
tree804ba82ff7d93af8aaf3afdbd5ef8f7d0b1508bc
parent7d2912de049ad6041f3b7c9f813e907c068acae1 (diff)
downloadzsh-4bab43d11d5ce60950e69e54ab5a677c15f13e0f.tar.gz
zsh-4bab43d11d5ce60950e69e54ab5a677c15f13e0f.zip
33046: new completion for "chsh"
-rw-r--r--ChangeLog6
-rw-r--r--Completion/Unix/Command/.distfiles1
-rw-r--r--Completion/Unix/Command/_chsh40
-rw-r--r--Completion/Unix/Type/_users2
4 files changed, 48 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f5dd2ad9b..a5dec47c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-08-23 Barton E. Schaefer <schaefer@zsh.org>
+
+ * 33046: Completion/Unix/Command/.distfiles,
+ Completion/Unix/Command/_chsh, Completion/Unix/Type/_users: new
+ completion for "chsh"
+
2014-08-22 Barton E. Schaefer <schaefer@zsh.org>
* 33042: NEWS, Src/jobs.c: $? and $pipestatus report 128+signal
diff --git a/Completion/Unix/Command/.distfiles b/Completion/Unix/Command/.distfiles
index fe810e1c4..35d81b2d2 100644
--- a/Completion/Unix/Command/.distfiles
+++ b/Completion/Unix/Command/.distfiles
@@ -29,6 +29,7 @@ _cdrecord
_chkconfig
_chmod
_chown
+_chsh
_clay
_comm
_compress
diff --git a/Completion/Unix/Command/_chsh b/Completion/Unix/Command/_chsh
new file mode 100644
index 000000000..97552e3ac
--- /dev/null
+++ b/Completion/Unix/Command/_chsh
@@ -0,0 +1,40 @@
+#compdef chsh chpass
+case $OSTYPE in
+(darwin*|*bsd*)
+ _arguments : \
+ '-s[Specify user login shell]:shell:(${(Z+Cn+)"$(</etc/shells)"})' \
+ "-l[Specify location of user]:node:" \
+ "-u[Specify authentication name]:auth user:" \
+ "1:user name:_users"
+ ;;
+(linux-gnu)
+ if { =chsh -v } >&/dev/null
+ then
+ local -a opts shells
+ shells=( $(=chsh -l) )
+ _arguments : \
+ "(-)-s[Specify your login shell]:shell:($shells)" \
+ "(-)--shell[Specify your login shell]:shell:($shells)" \
+ "(-)-l[Print shells in /etc/shells]" \
+ "(-)--list-shells[Print shells in /etc/shells]" \
+ "(-)-u[Print a usage message and exit]" \
+ "(-)--help[Print a usage message and exit]" \
+ "(-)-v[Print version information and exit]" \
+ "(-)--version[Print version information and exit]" \
+ "1:user name:_users"
+ return
+ fi
+ # else fall through
+ ;&
+(*)
+ local s=''
+ # Use $s to cause all options to be treated as mutually exclusive
+ [[ $words[CURRENT-1] = -* ]] && s="(-)$words[CURRENT-1]"
+ # This fiddling with $s is a hack to cause "_arguments : --" to use
+ # the /etc/shells listing for -s or --shell even when the description
+ # of that option has been pulled from the GNU --help output.
+ [[ $words[CURRENT-1] = (-s|--shell) ]] &&
+ s="$s"'[ ]:shell:(${(Z+Cn+)"$(</etc/shells)"})'
+ _arguments : $s "1:user name:_users" --
+ ;;
+esac
diff --git a/Completion/Unix/Type/_users b/Completion/Unix/Type/_users
index 5ab8dbc55..3c8c7027b 100644
--- a/Completion/Unix/Type/_users
+++ b/Completion/Unix/Type/_users
@@ -1,4 +1,4 @@
-#compdef passwd groups userdel chage chfn chsh
+#compdef passwd groups userdel chage chfn
local expl users