about summary refs log tree commit diff
path: root/Completion/Unix
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-11-12 04:07:15 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-11-12 04:07:15 +0000
commit65908383dabf87202a09fe21be82acf453e06234 (patch)
treed3670c4914a04dd47f77c2dde08d9735317c31c7 /Completion/Unix
parent2aa0c11efb9fe06cd5ba5233c04014d7431bb0f3 (diff)
downloadzsh-65908383dabf87202a09fe21be82acf453e06234.tar.gz
zsh-65908383dabf87202a09fe21be82acf453e06234.tar.xz
zsh-65908383dabf87202a09fe21be82acf453e06234.zip
Merge new completions onto 4.2 branch.
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Command/_cowsay28
-rw-r--r--Completion/Unix/Command/_env12
-rw-r--r--Completion/Unix/Command/_mkdir70
3 files changed, 110 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_cowsay b/Completion/Unix/Command/_cowsay
new file mode 100644
index 000000000..19e73811c
--- /dev/null
+++ b/Completion/Unix/Command/_cowsay
@@ -0,0 +1,28 @@
+#compdef cowsay cowthink
+
+local context state line
+typeset -A opt_args
+
+_arguments \
+  '-e:eye string:' \
+  '-f:cowfile:->cowfile' \
+  '-T:tongue string:' \
+  '-W:wrap column:' \
+  '-b[borg mode]' \
+  '-d[dead mode]' \
+  '-g[greedy mode]' \
+  '-h[help]' \
+  '-l[list]' \
+  '-n[no wordwrap]' \
+  '-p[paranoia mode]' \
+  '-s[stoned mode]' \
+  '-t[tired mode]' \
+  '-w[wired mode]' \
+  '-y[youthful mode]' \
+  ':message:' && return 0
+
+case "$state" in
+  (cowfile)
+  compadd ${=${(f)"$($service -l 2>/dev/null)"}:#*\:} || _files
+  ;;
+esac
diff --git a/Completion/Unix/Command/_env b/Completion/Unix/Command/_env
new file mode 100644
index 000000000..263818627
--- /dev/null
+++ b/Completion/Unix/Command/_env
@@ -0,0 +1,12 @@
+#compdef env
+
+if _pick_variant gnu=Free\ Soft unix --version; then
+  _arguments \
+    '(--ignore-environment -i)'{-i,--ignore-environment}'[start with empty environment]' \
+    {-u,--unset=}':env var to remove:compadd ${(k)parameters[(R)*export*]}' \
+    '--help[help]' \
+    '--version[version]' \
+    '*::arguments: _normal'
+else
+  _precommand
+fi
diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir
new file mode 100644
index 000000000..927b9dfe9
--- /dev/null
+++ b/Completion/Unix/Command/_mkdir
@@ -0,0 +1,70 @@
+#compdef mkdir
+
+local curcontext="$curcontext" line state \
+  args args_zsh args_cmd variant expl ret=1
+typeset -a opt_args
+
+args=(
+  '(-m --mode)'{-m,--mode=}'[set permission mode]:numeric mode'
+  '(-p --parents)'{-p,--parents}'[make parent directories as needed]'
+  )
+
+args_zsh=('(-)*: :->directories')
+
+args_cmd=(
+  '(-v --verbose)'{-v,--verbose}'[print message for each created directory]'
+  '(- :)--help[display help information]'
+  '(- :)--version[display version information]'
+  '*: :->directories'
+  )
+
+case "$OSTYPE" in
+  linux*)
+    args_cmd=(
+      '(-Z --context)'{-Z,--context=}'[set SELinux context]:SELinux context'
+      $args_cmd)
+    ;;
+esac
+
+_pick_variant -r variant gnu=gnu zsh='\(eval\)' unix --help
+
+# It can still happen that there is a precommand command or builtin in the line.
+# In such cases, the variant has to be modified suitably, after further checking
+# the variant of the _command_ mkdir.
+
+# I currently don't know of any way to find out what precommands are present on
+# the line. The variant should be modified like this once a way is found out:
+
+# if [[ $variant == zsh ]]; then
+#   if [[ $precommand = *command* ]]; then
+#     _mkdir_command () { command mkdir "$@" }
+#     _pick_variant -c _mkdir_command -r variant gnu=gnu unix --help
+#   fi
+# elif [[ $precommand = *builtin* ]]; then
+#   variant=zsh
+# fi
+
+if [[ $variant == zsh ]]; then
+  args+=($args_zsh)
+else
+  args+=($args_cmd)
+fi
+
+# remove long options?
+[[ $variant != gnu ]] && args=( ${${${args:#(|*\))--*}//--[^ )]#/}/\( #\)/} )
+
+_arguments -C -s $args && ret=0
+
+case "$state" in
+  directories)
+    if (( $ret )) && [[ ! -prefix - ]] || \
+      [[ $variant == zsh && ${#${${words[2,-1]}:#-*}} -gt 0 ]]; then
+      _wanted directories expl \
+	'parent directory (alternatively specify name of directory)' \
+	_path_files -/ || _message 'name of directory'
+      ret=0
+    fi
+    ;;
+esac
+
+return ret