summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Cook <illua@users.sourceforge.net>2016-06-14 21:26:58 -0400
committerEric Cook <illua@users.sourceforge.net>2016-06-14 21:26:58 -0400
commitbc1acf5b0e277ac3e5d7d57b9194b06931e5e406 (patch)
tree131f554802e1084b72835e6ed0a367b9658e584c
parent2162c1a2d2d86de4c2b956fb924c4d5acbbd0de9 (diff)
downloadzsh-bc1acf5b0e277ac3e5d7d57b9194b06931e5e406.tar.gz
zsh-bc1acf5b0e277ac3e5d7d57b9194b06931e5e406.tar.xz
zsh-bc1acf5b0e277ac3e5d7d57b9194b06931e5e406.zip
38676, 38680: Completion for pidof and localedef.
-rw-r--r--ChangeLog8
-rw-r--r--Completion/Linux/Command/_pidof24
-rw-r--r--Completion/Unix/Command/_localedef92
3 files changed, 124 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 06383ca14..83f346520 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-06-14  Eric Cook  <llua@gmx.com>
+
+	* 38676: Marko Myllynen: Completion/Linux/Command/_pidof:
+	Completion for pidof(1)
+
+	* 38680: Marko Myllynen: Completion/Unix/Command/_localedef:
+	Completion for localedef(1)
+
 2016-06-14  Doug Kearns  <dougkearns@gmail.com>
 
 	* unposted: Completion/Unix/Command/_cvs: remove unused parameter
diff --git a/Completion/Linux/Command/_pidof b/Completion/Linux/Command/_pidof
new file mode 100644
index 000000000..6605e7e67
--- /dev/null
+++ b/Completion/Linux/Command/_pidof
@@ -0,0 +1,24 @@
+#compdef pidof
+
+local curcontext="$curcontext" state line expl ret=1
+typeset -A opt_args
+
+local exargs="-h --help -V --version"
+_arguments -C -s -w \
+  '(- *)'{-h,--help}'[display help information]' \
+  '(- *)'{-V,--version}'[print program version]' \
+  "(-s --single-shot $exargs)"{-s,--single-shot}'[return one PID only]' \
+  "(-c --check-root $exargs)"{-c,--check-root}'[omit processes with different root]' \
+  "(-x $exargs)"-x'[include shells running named scripts]' \
+  "($exargs)"\*{-o+,--omit-pid}'[omit processes with PIDs]:pids:_sequence -s , _pids' \
+  '*:process:->procnames' \
+  && return 0
+
+case $state in
+  procnames)
+    # Handle defunct processes and "avahi-daemon:"
+    _wanted process-names expl process compadd ${${${${${(@)${(f)"$(ps -N --ppid 2 -p 2 o args=)"}%% *}##*/}%:}#\[}%]} && ret=0
+  ;;
+esac
+
+return ret
diff --git a/Completion/Unix/Command/_localedef b/Completion/Unix/Command/_localedef
new file mode 100644
index 000000000..78d231968
--- /dev/null
+++ b/Completion/Unix/Command/_localedef
@@ -0,0 +1,92 @@
+#compdef localedef
+
+local curcontext="$curcontext" state line expl ret=1
+typeset -A opt_args
+
+if _pick_variant gnu='(GNU|EGLIBC)' unix --version; then
+
+  local exargs="-? --help --usage -V --version"
+  _arguments -A "-*" -C -S -s \
+    '(- *)'{-\?,--help}'[display help information]' \
+    '(- *)--usage[display a short usage message]' \
+    '(- *)'{-V,--version}'[print program version]' \
+    "(-A --alias-file $exargs)"{-A+,--alias-file=}'[specify locale alias file]:alias file:_files' \
+    "($exargs)--prefix=[specify path prefix]:prefix:_files" \
+    "(-c --force $exargs)"{-c,--force}'[force write despite of warnings]' \
+    "(-v --verbose $exargs)"{-v,--verbose}'[display additional information]' \
+    "($exargs)--quiet[suppress messages and warnings]" \
+    - set1 \
+    "(-f --charmap $exargs)"{-f+,--charmap=}'[specify locale charmap file]:charmap:->charmap' \
+    "(-i --inputfile $exargs)"{-i+,--inputfile=}'[specify locale definition file]:locale file:_files' \
+    "(-u --repertoire-map $exargs)"{-u+,--repertoire-map=}'[specify repertoire map file]:repertoire map file:_files' \
+    '1:path:_files' \
+    - set2 \
+    "(--list-archive $exargs)--list-archive[list locales in archive]" \
+    - set3 \
+    "(--delete-from-archive $exargs)--delete-from-archive[delete locale from archive]" \
+    '*:locale:->locale' \
+    - set4 \
+    "(--add-to-archive $exargs)--add-to-archive[add locale to archive]" \
+    "(--replace $exargs)--replace[replace locale in archive]" \
+    "(--no-archive $exargs)--no-archive[use subdir not archive]" \
+    '*:compiled path:_files -/' \
+    && return 0
+
+  case "$state" in
+    charmap)
+      if [[ $words[-1] == */* ]]; then
+        _wanted charmaps expl charmap _files && ret=0
+      else
+        typeset -a charmaps
+        charmaps=( ${(f)"$(locale -m)"} )
+        _wanted charmaps expl charmap compadd -a charmaps && ret=0
+      fi
+    ;;
+    locale)
+      typeset -a locales
+      local pref=${opt_args[--prefix]}
+      local p=${pref:+--prefix}
+      locales=( ${(f)"$(localedef --list-archive $p $pref)"} )
+      _wanted locales expl locale compadd -a locales && ret=0
+    ;;
+  esac
+
+  return ret
+
+else
+
+  typeset -a u_opt bsd_opts
+  [[ $OSTYPE != darwin* ]] && u_opt=(
+      '-u+[specify target codeset]:codeset:_files'
+    )
+  [[ $OSTYPE == (freebsd*|dragonfly*) ]] && bsd_opts=(
+      '-D[create BSD-style output]' \
+      '-U[ignore undefined character symbols]' \
+      '-v[verbose deguggin output]' \
+      '-w+[specify width file]:width file:_files' \
+    )
+
+  _arguments -A "-*" -C \
+    '-c[force write despite of warnings]' \
+    '-f+[specify locale charmap file]:charmap:->charmap' \
+    '-i+[specify locale definition file]:locale file:_files' \
+    $u_opt \
+    $bsd_opts \
+    '1:path:_files' \
+    && return 0
+
+  case "$state" in
+    charmap)
+      if [[ $words[-1] == */* ]]; then
+        _wanted charmaps expl charmap _files && ret=0
+      else
+        typeset -a charmaps
+        charmaps=( ${(f)"$(locale -m)"} )
+        _wanted charmaps expl charmap compadd -a charmaps && ret=0
+      fi
+    ;;
+  esac
+
+  return ret
+
+fi