summaryrefslogtreecommitdiff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/.distfiles3
-rw-r--r--Completion/Unix/Command/_lp257
-rw-r--r--Completion/Unix/Command/_pgrep112
-rw-r--r--Completion/Unix/Command/_subversion42
-rw-r--r--Completion/Unix/Command/_unison92
-rw-r--r--Completion/Unix/Command/_xournal6
6 files changed, 460 insertions, 52 deletions
diff --git a/Completion/Unix/Command/.distfiles b/Completion/Unix/Command/.distfiles
index 0a158ee4b..3fcf8cc0f 100644
--- a/Completion/Unix/Command/.distfiles
+++ b/Completion/Unix/Command/.distfiles
@@ -146,6 +146,7 @@ _pbm
_perforce
_perl
_perldoc
+_pgrep
_php
_pine
_ping
@@ -222,6 +223,7 @@ _unace
_uname
_unexpand
_uniq
+_unison
_units
_user_admin
_uzbl
@@ -238,6 +240,7 @@ _wiggle
_xargs
_xmlsoft
_xmms2
+_xournal
_yafc
_yodl
_yp
diff --git a/Completion/Unix/Command/_lp b/Completion/Unix/Command/_lp
index ab0d53821..e6bff64cc 100644
--- a/Completion/Unix/Command/_lp
+++ b/Completion/Unix/Command/_lp
@@ -1,52 +1,219 @@
-#compdef lp lpr lpq lprm
+#compdef lp lpr lpq lprm lpoptions lpstat
local expl ret=1 printer list disp strs shown
-if compset -P '-[dP]' || [[ "$words[CURRENT-1]" = -[dP] ]]; then
- _printers
-else
- if [[ "$service" = (lpq|lprm) ]]; then
- if [[ "$words" = *-P* ]]; then
- printer=(-P "${${words##*-P( |)}%% *}")
- else
- printer=()
- fi
- list=( ${(M)"${(f@)$(_call_program jobs lpq $printer 2> /dev/null)}":#[0-9]*} )
-
- if (( $#list )); then
- _tags users jobs
-
- while _tags; do
- if _requested users; then
- strs=( "${(@)${(@)list##[^ ]##[ ]##[^ ]##[ ]##}%%[ ]*}" )
- if [[ -z "$shown" ]] &&
- zstyle -T ":completion:${curcontext}:users" verbose; then
- disp=(-ld list)
- shown=yes
- else
- disp=()
- fi
- _all_labels users expl user compadd "$disp[@]" -a strs ||
- _users && ret=0
- fi
- if _requested jobs; then
- strs=( "${(@)${(@)list##[^ ]##[ ]##[^ ]##[ ]##[^ ]##[ ]##}%%[ ]*}" )
- if [[ -z "$shown" ]] &&
- zstyle -T ":completion:${curcontext}:jobs" verbose; then
- disp=(-ld list)
- shown=yes
- else
- disp=()
- fi
- _all_labels jobs expl job compadd "$disp[@]" -a strs && ret=0
- fi
- (( ret )) || return 0
- done
+_lp_get_printer()
+{
+ # No reason to call _lp_get_printer when service == lpstat. Others matched
+ # below.
+ case $service in
+ (lpr|lpq|lprm)
+ [[ "$words" == (#I)*-P* ]] && printer="${${words##*(#I)-P( |)}%% *}"
+ ;;
+ (lp)
+ [[ "$words" == (#I)*-d* ]] && printer="${${words##*(#I)-d( |)}%% *}"
+ ;;
+ (lpoptions)
+ [[ "$words" == (#I)*-(d|p)* ]] && \
+ printer="${${words##*(#I)-(d|p)( |)}%% *}"
+ ;;
+ esac
+}
+
+_lp_job_options()
+{
+ local -a lopts_with_args lopts_no_args
+
+ # Generic options (from lp manual page)
+ lopts_with_args=( media orientation-requested sides number-up scaling cpi lpi
+ page-{bottom,left,right,top} )
+
+ lopts_no_args=(fitplot landscape)
+
+ _lp_get_printer
+ [[ -n "$printer" ]] && printer=(-p $printer)
+
+ # The program specified by the style list-printer-options should list jobs in
+ # the same style as lpoptions -l.
+ if compset -P '*='; then
+ # List values for the option
+ case ${IPREFIX%=} in
+ (media)
+ compadd "$@" a4 letter legal
+ ;;
+ (orientation-requested)
+ compadd "$@" 4
+ ;;
+ (sides)
+ compadd "$@" one-sided two-sided-{long,short}-edge
+ ;;
+ (number-up)
+ _description -V option-o-1 expl "pages per sheet"
+ compadd "$expl[@]" 2 4 6 9 16
+ ;;
+ (scaling|cpi|lpi|page-(bottom|left|right|top))
+ return 0; # Don't complete anything
+ ;;
+ (*)
+ compadd "$@" \
+ $(_call_program list-printer-options lpoptions $printer -l | \
+ grep "^${IPREFIX%=}" | cut -d: -f2 | tr -d \* )
+ ;;
+ esac
+ else
+ # List options
+ local eq_suffix
+
+ # Don't add an '=' suffix when completing lpoptions -r
+ if [[ $service == lpoptions && $words[CURRENT-1] == "-r" ]]; then
+ eq_suffix=()
else
- _message 'no print jobs'
+ eq_suffix=(-S '=')
fi
- return 1
+
+ _description lpopts expl "generic printer options"
+ compadd "$expl[@]" $eq_suffix $lopts_with_args
+ compadd "$expl[@]" $lopts_no_args
+
+ _description printeropts expl "printer specific options"
+ compadd "$expl[@]" $eq_suffix \
+ $(_call_program list-printer-options \
+ lpoptions $printer -l | cut -d/ -f1)
+ fi
+}
+
+_lp_list_jobs()
+{
+ _lp_get_printer
+ [[ -n "$printer" ]] && printer=(-P $printer)
+
+ list=( ${(M)"${(f@)$(_call_program jobs lpq $printer 2> /dev/null)}":#[0-9]*} )
+
+ if (( $#list )); then
+ _tags users jobs
+
+ while _tags; do
+ if _requested users; then
+ strs=( "${(@)${(@)list##[^ ]##[ ]##[^ ]##[ ]##}%%[ ]*}" )
+ if [[ -z "$shown" ]] &&
+ zstyle -T ":completion:${curcontext}:users" verbose;
+ then
+ disp=(-ld list)
+ shown=yes
+ else
+ disp=()
+ fi
+ _all_labels users expl user compadd "$disp[@]" -a strs ||
+ _users && ret=0
+ fi
+ if _requested jobs; then
+ strs=( "${(@)${(@)list##[^ ]##[ ]##[^ ]##[ ]##[^ ]##[ ]##}%%[ ]*}" )
+ if [[ -z "$shown" ]] &&
+ zstyle -T ":completion:${curcontext}:jobs" verbose; then
+ disp=(-ld list)
+ shown=yes
+ else
+ disp=()
+ fi
+ _all_labels jobs expl job compadd "$disp[@]" -a strs && ret=0
+ fi
+ (( ret )) || return 0
+ done
else
- _pspdf
+ _message 'no print jobs'
fi
-fi
+ return 1
+}
+
+case $service in
+ (lpq)
+ _arguments \
+ '-E[Force encryption]' \
+ '-U:username (for connection to server):_users' \
+ '-h:alternate server:_hosts' \
+ '(-a)-P+[destination printer]:printers:_printers' \
+ '(-P)-a[all printers]' \
+ '-l[long listing]' \
+ '*:poll interval (+seconds):'
+ ;;
+
+ (lprm)
+ _arguments \
+ '-E[Force encryption]' \
+ '-U:username (for connection to server):_users' \
+ '-h:alternate server:_hosts' \
+ '-P+[destination printer]:printers:_printers' \
+ '*:job ids:_lp_list_jobs'
+ ;;
+
+ (lpoptions)
+ _arguments \
+ '-E[Force encryption]' \
+ '-U:username (for connection to server):_users' \
+ '-h:alternate server:_hosts' \
+ '(-p -l -r -x)-d[set default printer]:printers:_printers' \
+ '(-l -x)*-o:job options:_lp_job_options' \
+ '(-d -x)-p[destination printer for options]:printers:_printers' \
+ '(-d -o -r -x)-l[list options]' \
+ '(-d -l -x)*-r:remove option:_lp_job_options' \
+ '(-d -l -r -o)-x[remove all options]:printers:_printers'
+ ;;
+
+ (lpstat)
+ _arguments \
+ '-E[Force encryption]' \
+ '-R[Shows print job ranking]' \
+ '-U:username (for connection to server):_users' \
+ '-W:which jobs:(completed not-completed)' \
+ '-a[Show accepting state]:printers:_printers' \
+ '-c:printer classes:' \
+ '-d[Show current default destination]' \
+ '-h:hostname (alternate server):_hosts' \
+ '-l[long listing]' \
+ '-o[destinations]:printers:_printers' \
+ '-p:printers:_printers' \
+ '-r[CUPS server running status]' \
+ '-s[Status summary]' \
+ '-t[All status info]' \
+ '-u[list jobs by users]:users:_users' \
+ '-v[show devices]:printers:_printers'
+ ;;
+
+ (lpr)
+ _arguments \
+ '-E[Force encryption]' \
+ '-H:hostname (alternate server):_hosts' \
+ '(-C -J -T)'-{C,J,T}':job name:' \
+ '-P+[destination printer]:printers:_printers' \
+ '-U:username (for connection to server):_users' \
+ '-#[Copies]:copies (1--100):' \
+ '-h[Disables banner printing]' \
+ '-l[raw file]' \
+ '-m[Send an email on job completion]' \
+ '*-o:print job options:_lp_job_options' \
+ '-p[format with shaded header incl. date, time etc.]' \
+ '-q[Hold job for printing.]' \
+ '-r[delete files after printing]' \
+ '*:PS/PDF files:_pspdf'
+ ;;
+
+ (lp)
+ _arguments \
+ '-E[Force encryption]' \
+ '-U[username (for connection to server)]:username:_users' \
+ '-c[(OBSOLETE) copy to spool dir before printing]' \
+ '-d[destination printer]:printers:_printers' \
+ '-h:hostname (alternate server):_hosts' \
+ '-i[job id to modify]:job id:' \
+ '-m[Send an email on job completion]' \
+ '-n[Copies]:copies (1--100):' \
+ '*-o:print job options:_lp_job_options' \
+ '-q[Job priority -- 1 (lowest) to 100 (highest)]:priority:' \
+ '-s[Dont report resulting job IDs]' \
+ '-t[Sets the job name]:job name:' \
+ '-u[job submission username]:username:_users' \
+ '-H[Time to print]:print time (or enter hh\:mm):(hold immediate restart resume)' \
+ '-P:page range list:' \
+ '*:PS/PDF files:_pspdf'
+ ;;
+esac
diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep
new file mode 100644
index 000000000..f65324a81
--- /dev/null
+++ b/Completion/Unix/Command/_pgrep
@@ -0,0 +1,112 @@
+#compdef pgrep pkill
+
+local context state line
+typeset -A opt_args
+typeset -a arguments
+
+arguments=('-P[parent process id]:parent process id:->ppid'
+ '-g[match only in process group ids]:group:->pgid'
+ '-G[match only real group id]:group:->group'
+ '-s[match only session id]:session id:->sid'
+ '-t[match only controlled by terminal]:terminal device:->tty'
+ '-u[match only effective user id]:user:->user'
+ '-U[match only real user id]:user:->user'
+ '(-n)-o[oldest process]'
+ '(-o)-n[newest process]'
+ '-f[match against full command line]'
+ '-v[negate matching]'
+ '-x[match exactly]'
+ '*:process name:->pname')
+
+if [[ $service == 'pkill' ]]
+then
+ arguments+=('-'${^signals}'[signal]')
+elif [[ $service == 'pgrep' ]]
+then
+ arguments+=('-d[output delimiter]:delimiter:compadd ${(s\:\:)IFS}'
+ '-l[list name in addition to id]')
+fi
+
+_arguments -s -w $arguments
+
+case $state in
+ (tty)
+ compset -P '*,'
+
+ local -a used
+ used=(${(s:,:)IPREFIX})
+
+ compadd -S ',' -q -F used /dev/tty*(:t)
+ ;;
+
+ (sid)
+ compset -P '*,'
+
+ local -a used sid
+ used=(${(s:,:)IPREFIX})
+ sid=(${(uon)$(ps -A o sid=)})
+
+ compadd -S ',' -q -F used $sid
+ ;;
+
+ (ppid)
+ compset -P '*,'
+
+ local -a used ppid
+ used=(${(s:,:)IPREFIX})
+ ppid=(${(uon)$(ps -A o ppid=)})
+
+ compadd -S ',' -q -F used $ppid
+ ;;
+
+ (pgid)
+ compset -P '*,'
+
+ local -a used pgid
+ used=(${(s:,:)IPREFIX})
+ pgid=(${(uon)$(ps -A o pgid=)})
+
+ compadd -S ',' -q -F used $pgid
+ ;;
+
+ (pname)
+ if (( ${+opt_args[-x]} )) && (( ${+opt_args[-f]} ))
+ then
+ compadd ${(u)${(f)"$(ps -A o cmd=)"}}
+ else
+ compadd ${(u)${(f)"$(ps -A co cmd=)"}}
+ fi
+ ;;
+
+ (group)
+ compset -P '*,'
+
+ local group
+ group=$(getent group)
+
+ local -a groups ids
+ groups=(${${(f)group}%%:*})
+ ids=(${${${(f)group}#*:*:}%%:*})
+
+ local -a used
+ used=(${(s:,:)IPREFIX})
+
+ compadd -S ',' -q -F used -d ids $groups $groups
+ ;;
+
+ (user)
+ compset -P '*,'
+
+ local passwd
+ passwd=$(getent passwd)
+
+ local -a users ids
+ users=(${${(f)passwd}%%:*})
+ ids=(${${${(f)passwd}#*:*:}%%:*})
+
+ local -a used
+ used=(${(s:,:)IPREFIX})
+
+ compadd -S ',' -q -F used -d ids $users $users
+ ;;
+esac
diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion
index f0dbb5fc2..44d83b7fe 100644
--- a/Completion/Unix/Command/_subversion
+++ b/Completion/Unix/Command/_subversion
@@ -4,6 +4,12 @@ _svn () {
local curcontext="$curcontext" state line expl ret=1
typeset -A opt_args
+ local update_policy
+ zstyle -s ":completion:*:*:$service:*" cache-policy update_policy
+ if [[ -z "$update_policy" ]]; then
+ zstyle ":completion:*:*:$service:*" cache-policy _svn_caching_policy
+ fi
+
_arguments -C \
'(-)--help[print help information]' \
'(- *)--version[print client version information]' \
@@ -12,9 +18,12 @@ _svn () {
if [[ -n $state ]] && (( ! $+_svn_cmds )); then
typeset -gHA _svn_cmds
- _svn_cmds=(
- ${=${(f)${${"$(LC_ALL=C _call_program commands svn help)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
- )
+ if ! _cache_invalid svn_cmds && ! _retrieve_cache svn_cmds; then
+ _svn_cmds=(
+ ${=${(f)${${"$(LC_ALL=C _call_program commands svn help)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
+ )
+ _store_cache svn_cmds _svn_cmds
+ fi
fi
case $state in
@@ -29,10 +38,20 @@ _svn () {
if (( $#cmd )); then
curcontext="${curcontext%:*:*}:svn-${cmd}:"
- usage=${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] }
- args=(
- ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
- )
+ if ! _cache_invalid svn-${cmd}-usage && \
+ ! _retrieve_cache svn-${cmd}-usage;
+ then
+ usage=${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] }
+ _store_cache svn-${cmd}-usage usage
+ fi
+ if ! _cache_invalid svn-${cmd}-usage && \
+ ! _retrieve_cache svn-${cmd}-args;
+ then
+ args=(
+ ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
+ )
+ _store_cache svn-${cmd}-args args
+ fi
case $cmd in;
(add)
@@ -297,4 +316,13 @@ _subversion () {
esac
}
+_svn_caching_policy() {
+ # Rebuild every week
+ local -a oldp
+
+ oldp=( "$1"(Nmw+1) )
+ (( $#oldp ))
+}
+
+
_subversion "$@"
diff --git a/Completion/Unix/Command/_unison b/Completion/Unix/Command/_unison
new file mode 100644
index 000000000..bb8edd489
--- /dev/null
+++ b/Completion/Unix/Command/_unison
@@ -0,0 +1,92 @@
+#compdef unison
+
+local context state line
+typeset -A opt_args
+
+_arguments \
+ '-auto[automatically accept default (nonconflicting) actions]' \
+ '-batch[batch mode\: ask no questions at all]' \
+ '-doc[show documentation]:topics:(about people lists status copying ack install tutorial basics failures running ssh news all topics)' \
+ '-follow[add a pattern to the follow list]:pattern:' \
+ '-force[force changes from this replica to the other]:replica:' \
+ '-group[synchronize group attributes]' \
+ '-ignore[add a pattern to the ignore list]:pattern:' \
+ '-ignorenot[add a pattern to the ignorenot list]:pattern:' \
+ '-owner[synchronize owner]' \
+ '-path[path to synchronize]:path:_files' \
+ '-perms[part of the permissions which is synchronized]:perms:' \
+ '-prefer[choose this replicas version for conflicting changes]:replica:' \
+ '-root[root of a replica (should be used exactly twice)]:path:_files -/' \
+ '-silent[print nothing except error messages]' \
+ '-terse[suppress status messages]' \
+ '-testserver[exit immediately after the connection to the server]' \
+ '-times[synchronize modification times]' \
+ '-version[print version and exit]' \
+ '-addprefsto[add new prefs to]:file:_files' \
+ '-addversionno[add version number to name of unison on server]' \
+ '-backup[add a pattern to the backup list]:pattern:' \
+ '-backupcurr[add a pattern to the backupcurr list]:pattern:' \
+ '-backupcurrnot[add a pattern to the backupcurrnot list]:pattern:' \
+ '-backupdir[directory for storing centralized backups]:directory:_files -/' \
+ '-backuploc[where backups are stored]:backup location:(local central)' \
+ '-backupnot[add a pattern to the backupnot list]:pattern:' \
+ '-backupprefix[prefix for the names of backup files]:prefix:' \
+ '-backups[keep backup copies of all files]' \
+ '-backupsuffix[a suffix to be added to names of backup files]:suffix:' \
+ '-confirmbigdel[ask about whole-replica (or path) deletes (default true)]' \
+ '-confirmmerge[ask for confirmation before commiting results of a merge]' \
+ '-contactquietly[suppress the "contacting server" message during startup]' \
+ '-copyprog[external program for copying large files]:program:_files -g "*(-x)"' \
+ '-copyprogrest[variant of copyprog for resuming partial transfers]:program:_files -g "*(-x)"' \
+ '-copyquoterem[add quotes to remote file name for copyprog]:quote style:(true false default)]' \
+ '-copythreshold[use copyprog on files bigger than this]:size (kb):' \
+ '-debug:debug module:(all verbose)' \
+ '-diff[command for showing differences between files]:program:_files -g "*(-x)"' \
+ '-dontchmod[When set, never use the chmod system call]' \
+ '-dumbtty[do not change terminal settings in text UI]' \
+ '-fastcheck:fast update detection:(true false default)' \
+ '-forcepartial[add a pattern to the forcepartial list]:pattern:' \
+ '-height[height of main window in graphical interface]:number (lines):' \
+ '-host[bind the socket to this host name in server socket mode]:host:_hosts' \
+ '-ignorecase[identify upper/lowercase filenames]:ignorecase:(true false default)' \
+ '-ignorelocks[ignore locks left over from previous run (dangerous!)]' \
+ '-immutable[add a pattern to the immutable list]:pattern:' \
+ '-immutablenot[add a pattern to the immutablenot list]:pattern:' \
+ '-key[define a keyboard shortcut for this profile (in some UIs)]:shortcut:' \
+ '-killserver[kill server when done (even when using sockets)]' \
+ '-label[provide a descriptive string label for this profile]:label:' \
+ '-log[record actions in logfile (default true)]' \
+ '-logfile:logfile name:_files' \
+ '-maxbackups[number of backed up versions of a file]:number:' \
+ '-maxthreads[maximum number of simultaneous file transfers]:number:' \
+ '-merge[add a pattern to the merge list]:pattern:' \
+ '-mountpoint[abort if this path does not exist]:mountpoint:_files -/' \
+ '-numericids[dont map uid/gid values by user/group names]' \
+ '-preferpartial[add a pattern to the preferpartial list]:pattern:' \
+ '-pretendwin[Use creation times for detecting updates]' \
+ '-repeat[synchronize repeatedly (text interface only)]:repeat:' \
+ '-retry[re-try failed synchronizations N times (text ui only)]:retry times:' \
+ '-rootalias[register alias for canonical root names]:root alias:' \
+ '-rsrc:synchronize resource forks:(true false default)' \
+ '-rsync[activate the rsync transfer mode (default true)]' \
+ '-selftest[run internal tests and exit]' \
+ '-servercmd[name of unison executable on remote server]:program:_files -g "*(-x)"' \
+ '-showarchive[show "true names" (for rootalias) of roots and archive]' \
+ '-socket[act as a server on a socket]:socket:_files -g "*(-=)"' \
+ '-sortbysize[list changed files by size, not name]' \
+ '-sortfirst[add a pattern to the sortfirst list]:pattern:' \
+ '-sortlast[add a pattern to the sortlast list]:pattern:' \
+ '-sortnewfirst[list new before changed files]' \
+ '-sshargs[other arguments (if any) for remote shell command]:ssh args:' \
+ '-sshcmd[path to the ssh executable]:program:_files -g "*(-x)"' \
+ '-ui:user interface:(text graphic)' \
+ '-xferbycopying[optimize transfers using local copies (default true)]' \
+ '*:profile:->profile'
+
+if [[ $state == profile ]]; then
+ local -a profiles
+
+ profiles=( ~/.unison/*.prf(N) )
+ (( $#profiles )) && \
+ compadd "$@" - ${${profiles#~/.unison/}%.prf}
+fi
diff --git a/Completion/Unix/Command/_xournal b/Completion/Unix/Command/_xournal
new file mode 100644
index 000000000..066ef55f5
--- /dev/null
+++ b/Completion/Unix/Command/_xournal
@@ -0,0 +1,6 @@
+#compdef xournal
+
+local expl
+
+_description files expl 'PDF and Xournal files'
+_files "$@" "$expl[@]" -g '*.(#i){xoj,pdf}(-.)'