diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-08-23 10:07:17 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-08-23 10:07:17 +0000 |
commit | f7fa32f091420552d5dbb16ff5f574484508f1de (patch) | |
tree | 82be5f077e6cdddad82a015f77a0308d825cd951 /Completion/User | |
parent | 16060224ac17a8b5a1efb8568643f9a15b14c034 (diff) | |
download | zsh-f7fa32f091420552d5dbb16ff5f574484508f1de.tar.gz zsh-f7fa32f091420552d5dbb16ff5f574484508f1de.tar.xz zsh-f7fa32f091420552d5dbb16ff5f574484508f1de.zip |
zsh-workers/7463
Diffstat (limited to 'Completion/User')
-rw-r--r-- | Completion/User/_chown | 8 | ||||
-rw-r--r-- | Completion/User/_dir_list | 4 | ||||
-rw-r--r-- | Completion/User/_exec_funcs | 49 | ||||
-rw-r--r-- | Completion/User/_find | 3 | ||||
-rw-r--r-- | Completion/User/_gprof | 12 | ||||
-rw-r--r-- | Completion/User/_rlogin | 2 | ||||
-rw-r--r-- | Completion/User/_su | 5 | ||||
-rw-r--r-- | Completion/User/_tar | 2 | ||||
-rw-r--r-- | Completion/User/_users | 6 |
9 files changed, 78 insertions, 13 deletions
diff --git a/Completion/User/_chown b/Completion/User/_chown index c75dbc4b3..3a14d3f89 100644 --- a/Completion/User/_chown +++ b/Completion/User/_chown @@ -4,14 +4,10 @@ if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then if [[ $words[1] = chgrp ]] || compset -P '*[:.]'; then _groups else - local expl - - _description expl user - if [[ $OSTYPE = (solaris*|hpux*) ]]; then - compgen "$expl[@]" -u -S ':' -q + _users -S ':' -q else - compgen "$expl[@]" -u -S '.' -q + _users -S '.' -q fi fi else diff --git a/Completion/User/_dir_list b/Completion/User/_dir_list new file mode 100644 index 000000000..8e3615dac --- /dev/null +++ b/Completion/User/_dir_list @@ -0,0 +1,4 @@ +#autoload + +compset -P '*:' +_files -S: -r ': \t\t\-' -/ diff --git a/Completion/User/_exec_funcs b/Completion/User/_exec_funcs new file mode 100644 index 000000000..2fd64b230 --- /dev/null +++ b/Completion/User/_exec_funcs @@ -0,0 +1,49 @@ +#autoload + +# This should be called from `_arguments' or otherwise the calling +# function has to set up an array named `line' that contains the +# name of the executable as its seconf element or it has to supply +# that name as an argument. +# One option is recognized: `-p' means that we are completing a pair +# of names separated by a slash. + +local cmd pair expl + +if [[ "$1" = -p ]]; then + pair=yes + shift +fi + +if (( $# )); then + cmd="$1" +elif [[ $#line -gt 1 ]]; then + cmd="$line[2]" +else + return 1 +fi + +if [[ -n "$cmd" ]]; then + if [[ "$cmd" = /* ]]; then + tmp="$cmd" + else + tmp="$PWD/$cmd" + fi + + if [[ "$tmp" != "$_es_command" ]]; then + _es_command="$tmp" + _es_funcs=( "${(@)${(@M)${(@f)$(nm $cmd)}:#[^ ]# [tT] ([^_]|_[^_])*}##* }" ) + fi + + if [[ -n "$pair" ]]; then + if compset -P '*/'; then + _description expl 'call arc to function' + else + _description expl 'call arc from function' + fi + else + _description expl function + fi + compadd -M 'r:|_=* r:|=*' - "$_es_funcs[@]" +else + return 1 +fi diff --git a/Completion/User/_find b/Completion/User/_find index 20e8f4ff7..3ccb14c32 100644 --- a/Completion/User/_find +++ b/Completion/User/_find @@ -27,6 +27,5 @@ elif [[ "$prev" = -fstype ]]; then elif [[ "$prev" = -group ]]; then _groups elif [[ "$prev" = -user ]]; then - _description expl user - compgen "$expl[@]" -u + _users fi diff --git a/Completion/User/_gprof b/Completion/User/_gprof new file mode 100644 index 000000000..0a1d621be --- /dev/null +++ b/Completion/User/_gprof @@ -0,0 +1,12 @@ +#compdef gprof + +_arguments -s -{a,b,c,D,h,i,l,L,s,T,v,w,x,y,z} \ + -{A,C,e,E,f,F,J,n,N,O,p,P,q,Q,Z}:'function name: _exec_funcs' \ + '-I:directory:_dir_list' \ + '-d-:debug level:' '-k:function names: _exec_funcs -p' \ + '-m:minimum execution count:' \ + ':executable:_files -g *(*)' \ + ':profile file:_files -g gmon.*' \ + -- -s '(#--[no-] --)' \ + '*=name*:function name: _exec_funcs' \ + '*=dirs*:directory:_dir_list' diff --git a/Completion/User/_rlogin b/Completion/User/_rlogin index 8756ec42d..e61890702 100644 --- a/Completion/User/_rlogin +++ b/Completion/User/_rlogin @@ -15,5 +15,5 @@ if [[ CURRENT -eq 2 ]]; elif [[ CURRENT -eq 3 ]]; then compadd - -l else - compgen "$expl[@]" -S @ -u + _users -S @ fi diff --git a/Completion/User/_su b/Completion/User/_su index 7b9744cd9..df1b89f97 100644 --- a/Completion/User/_su +++ b/Completion/User/_su @@ -1,13 +1,12 @@ #compdef su -local shell comp name usr base expl +local shell comp name usr base [[ $words[2] != - ]] (( base=$?+2 )) if [[ CURRENT -eq base ]]; then - _description expl user - compgen "$expl[@]" -u && return + _users && return usr=root elif [[ CURRENT -ge base+1 ]]; then usr=$words[base] diff --git a/Completion/User/_tar b/Completion/User/_tar index 02551759a..8135bf006 100644 --- a/Completion/User/_tar +++ b/Completion/User/_tar @@ -72,7 +72,7 @@ if [[ "$PREFIX" = --* ]]; then # ...long options after `--'. - _long_options '--owner*:user:_tilde' \ + _long_options '--owner*:user:_users' \ '*=(PROG|COMMAND)*:program:_command_names' \ '*=ARCHIVE*:archive: _tar_archive' \ '*=NAME*:file:_files' \ diff --git a/Completion/User/_users b/Completion/User/_users new file mode 100644 index 000000000..fc1e87e52 --- /dev/null +++ b/Completion/User/_users @@ -0,0 +1,6 @@ +#autoload + +local expl + +_description expl user +compgen "$@" "$expl[@]" -u |