diff options
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r-- | Completion/Unix/Command/.distfiles | 4 | ||||
-rw-r--r-- | Completion/Unix/Command/_getconf | 2 | ||||
-rw-r--r-- | Completion/Unix/Command/_git | 1 | ||||
-rw-r--r-- | Completion/Unix/Command/_gradle | 114 | ||||
-rw-r--r-- | Completion/Unix/Command/_init_d | 1 | ||||
-rw-r--r-- | Completion/Unix/Command/_mosh | 12 | ||||
-rw-r--r-- | Completion/Unix/Command/_mount | 9 | ||||
-rw-r--r-- | Completion/Unix/Command/_quilt | 22 | ||||
-rw-r--r-- | Completion/Unix/Command/_ssh | 13 | ||||
-rw-r--r-- | Completion/Unix/Command/_systemctl | 311 | ||||
-rw-r--r-- | Completion/Unix/Command/_systemd | 459 | ||||
-rw-r--r-- | Completion/Unix/Command/_tmux | 26 | ||||
-rw-r--r-- | Completion/Unix/Command/_wget | 2 | ||||
-rw-r--r-- | Completion/Unix/Command/_xmlsoft | 6 | ||||
-rw-r--r-- | Completion/Unix/Command/_zfs | 342 | ||||
-rw-r--r-- | Completion/Unix/Command/_zpool | 190 |
16 files changed, 1042 insertions, 472 deletions
diff --git a/Completion/Unix/Command/.distfiles b/Completion/Unix/Command/.distfiles index e54c6c0d2..355cb9cf9 100644 --- a/Completion/Unix/Command/.distfiles +++ b/Completion/Unix/Command/.distfiles @@ -83,6 +83,7 @@ _go _gpg _gphoto2 _gprof +_gradle _graphicsmagick _grep _groff @@ -130,6 +131,7 @@ _mh _mkdir _module _monotone +_mosh _mount _mpc _mt @@ -211,7 +213,7 @@ _subversion _sudo _surfraw _sysctl -_systemctl +_systemd _tar _tardy _tcpdump diff --git a/Completion/Unix/Command/_getconf b/Completion/Unix/Command/_getconf index 76d9c7686..f2c713a52 100644 --- a/Completion/Unix/Command/_getconf +++ b/Completion/Unix/Command/_getconf @@ -27,7 +27,7 @@ if [[ CURRENT -eq 2 ]]; then _tags syswideconfig pathconfig standardsconfig confstring restconfig allkeys=(${${(f)"$(getconf -a 2>/dev/null)"}%%[: ]*}) - restkeys=(${allkeys:#(${(j.|.)~mykeys})}) + restkeys=(${allkeys:|mykeys}) while _tags; do _requested -V syswideconfig expl 'systemwide configuration variables' \ diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 5ed921850..88c765fb0 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -5753,6 +5753,7 @@ __git_setup_merge_options () { '(--stat -n --no-stat)'{-n,--no-stat}'[do not show diffstat at the end of the merge]' '( --no-squash)--squash[merge, but do not commit]' '(--squash )--no-squash[merge and commit]' + '--ff-only[refuse to merge unless HEAD is up to date or merge can be resolved as a fast-forward]' '*'{-s,--strategy=}'[use given merge strategy]:merge strategy:__git_merge_strategies' '*'{-X,--strategy-option=}'[pass merge-strategy-specific option to merge strategy]' '(-q --quiet -v --verbose)'{-q,--quiet}'[suppress all output]' diff --git a/Completion/Unix/Command/_gradle b/Completion/Unix/Command/_gradle new file mode 100644 index 000000000..bc5aed0cd --- /dev/null +++ b/Completion/Unix/Command/_gradle @@ -0,0 +1,114 @@ +#compdef gradle gradlew + +local curcontext="$curcontext" ret=1 state state_descr line +local gradle_inspect=yes cache_policy tag_order +local -A opt_args +local -a gradle_group_tasks gradle_all_tasks + +# Set the caching policy to invalidate cache if the build file is newer than the cache. +_gradle_caching_policy() { + [[ $gradle_buildfile -nt $1 ]] +} + +zstyle -s ":completion:*:*:$service:*" cache-policy cache_policy || \ + zstyle ":completion:*:*:$service:*" cache-policy _gradle_caching_policy + +# By default, we only complete main tasks (belonging to a group). Secondary tasks are +# completed if no main tasks are found. +zstyle -a ":completion:*:*:$service:*" tag-order tag_order || \ + zstyle ":completion:*:*:$service:*" tag-order 'gradle_group' 'gradle_all' + +# The completion inspects the current build file to find tasks to complete. Setting +# this style to 'no' or 'false' turns off inspection. In that case only the built-in tasks +# are completed. +zstyle -T ":completion:*:*:$service:*" gradle-inspect || gradle_inspect=no + +_arguments -C \ + '(-)'{-\?,-h,--help}'[Shows this help message.]' \ + {-a,--no-rebuild}'[Do not rebuild project dependencies.]' \ + {-b,--build-file}'[Specifies the build file.]:build file:_files -g "*.gradle(-.)"' \ + {-C,--cache}'[Specifies how compiled build scripts should be cached.]:cache policy:(on rebuild)' \ + {-c,--settings-file}'[Specifies the settings file.]:settings file:_files -g "*.properties(-.)"' \ + '--continue[Continues task execution after a task failure.]' \ + \*{-D+,--system-prop}'[Set system property of the JVM (e.g. -Dmyprop=myvalue).]:system property (prop=val):' \ + '(-i --info -q --quiet)'{-d,--debug}'[Log in debug mode (includes normal stacktrace).]' \ + '(--nodaemon)--daemon[Uses the Gradle daemon to run the build. Starts the daemon if not running.]' \ + '--foreground[Starts the Gradle daemon in the foreground.]' \ + {-g,--gradle-user-home}'[Specifies the gradle user home directory.]:home directory:_directories' \ + '(-)--gui[Launches the Gradle GUI.]' \ + {-I,--init-script}'[Specifies an initialization script.]:init script:_files -g "*.gradle(-.)"' \ + '(-d --debug -q --quiet)'{-i,--info}'[Set log level to info.]' \ + {-m,--dry-run}'[Runs the builds with all task actions disabled.]' \ + '--no-color[Do not use color in the console output.]' \ + '(--daemon)--no-daemon[Do not use the Gradle daemon to run the build.]' \ + '--no-opt[Ignore any task optimization.]' \ + '--offline[The build should operate without accessing network resources.]' \ + \*{-P+,--project-prop}'[Set project property for the build script (e.g. -Pmyprop=myvalue).]:project property (prop=val):' \ + {-p,--project-dir}'[Specifies the start directory for Gradle.]:start directory:_directories' \ + '--profile[Profiles build execution time and generates a report in the <build_dir>/reports/profile directory.]' \ + '--project-cache-dir[Specifies the project-specific cache directory.]:cache directory:_directories' \ + '(-d --debug -i --info)'{-q,--quiet}'[Log errors only.]' \ + "--refresh[Refresh the state of resources of the type(s) specified.]:refresh policy:(dependencies)" \ + '(-s --stacktrace)'{-S,--full-stacktrace}'[Print out the full (very verbose) stacktrace for all exceptions.]' \ + '(-S --full-stacktrace)'{-s,--stacktrace}'[Print out the stacktrace for all exceptions.]' \ + '(-)--stop[Stops the Gradle daemon if it is running.]' \ + {-u,--no-search-upward}"[Don't search in parent folders for a settings.gradle file.]" \ + '(-)'{-v,--version}'[Print version info.]' \ + {-x,--exclude-task}'[Specify a task to be excluded from execution.]:task to exclude:->alltask' \ + '*:task:->task' \ + && ret=0 + +if [[ -n $state ]]; then + if [[ $gradle_inspect == yes ]]; then + # If a build file is specified after '-b' or '--build-file', use this file. Otherwise, + # default is the file 'build.gradle' in the current directory. + local gradle_buildfile=${${(v)opt_args[(i)-b|--build-file]}:-build.gradle} + + if [[ -f $gradle_buildfile ]]; then + # Cache name is constructed from the absolute path of the build file. + local cache_name=${${gradle_buildfile:a}//[^[:alnum:]]/_} + if _cache_invalid $cache_name || ! _retrieve_cache $cache_name; then + zle -R "Generating cache from $gradle_buildfile" + local outputline + local -a match mbegin mend + # Run gradle/gradlew and retrieve possible tasks. + for outputline in ${(f)"$($service --build-file $gradle_buildfile -q tasks --all)"}; do + if [[ $outputline == [[:blank:]]#(#b)([[:alnum:]]##)' - '(*) ]]; then + # The descriptions of main tasks start at beginning of line, descriptions of + # secondary tasks are indented. + if [[ $outputline == [[:alnum:]]* ]]; then + gradle_group_tasks+=( "$match[1]:$match[2]" ) + else + gradle_all_tasks+=( "$match[1]:$match[2]" ) + fi + fi + done + _store_cache $cache_name gradle_group_tasks gradle_all_tasks + fi + + if [[ $state == task ]]; then + _tags gradle_group gradle_all + while _tags; do + # Offer main tasks and secondary tasks in different tags. + _requested gradle_group && _describe 'group tasks' gradle_group_tasks && ret=0 + _requested gradle_all && _describe 'secondary tasks' gradle_all_tasks && ret=0 + (( ret )) || break + done + elif [[ $state == alltask ]]; then + # After '--exclude-task', we don't make a distinction between main tasks and + # secondary tasks. + _describe 'all tasks' gradle_group_tasks -- gradle_all_tasks && ret=0 + fi + fi + else + _describe 'built-in tasks' '( + "dependencies:Displays the dependencies of root project." + "help:Displays a help message." + "projects:Displays the sub-projects of root project." + "properties:Displays the properties of root project." + "tasks:Displays the tasks runnable from root project." + )' && ret=0 + fi +fi + +return ret diff --git a/Completion/Unix/Command/_init_d b/Completion/Unix/Command/_init_d index dd9933a46..bbf62fc0d 100644 --- a/Completion/Unix/Command/_init_d +++ b/Completion/Unix/Command/_init_d @@ -68,6 +68,7 @@ else what='(st(art|op|atus)|(force-|)re(start|load)|debug_(up|down)|dump(|_stats)|add|delete|clean|list)' + [[ -x $script ]] || return 1 read -u0 -k2 magic < $script && [[ $magic = '#!' ]] && cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $script)"}:#[[:blank:]]#(\'|)${~what}([[:blank:]]#\|[[:blank:]]#${~what})#(\'|)\)}}//[^-a-z_]} ) diff --git a/Completion/Unix/Command/_mosh b/Completion/Unix/Command/_mosh new file mode 100644 index 000000000..c940f9015 --- /dev/null +++ b/Completion/Unix/Command/_mosh @@ -0,0 +1,12 @@ +#compdef mosh + +_arguments \ + '--client=:client helper:_command_names -e' \ + '--server=:server helper:_files' \ + '--ssh=:ssh command to run:_files' \ + '(-a -n)--predict=:when:(adaptive always never)' \ + '(--predict -n)-a[predict always]' \ + '(--predict -a)-n[predict never]' \ + {-p,--port=}':port:_ports' \ + ':remote:_hosts' \ + ':remote command:_command_names -e' diff --git a/Completion/Unix/Command/_mount b/Completion/Unix/Command/_mount index 409d253ab..b48aaa236 100644 --- a/Completion/Unix/Command/_mount +++ b/Completion/Unix/Command/_mount @@ -690,7 +690,7 @@ if [[ "$service" = mount ]]; then deffs=hsfs typeops=-F ;; - freebsd*|dragonfly*) + freebsd*|dragonfly*|darwin*) args=( -s '(:)-a[mount all filesystems in fstab]' '-d[cause everything to be done except for the actual system call]' @@ -765,7 +765,7 @@ else '*:dev or dir:->udevordir' ) ;; - freebsd*|dragonfly*) + freebsd*|dragonfly*|darwin*) args=( '(*)-a[unmount all mounted file systems]' '-A[unmount all mounted file systems except the root]' @@ -904,6 +904,11 @@ udevordir) mp_tmp+=( $mline[(w)3] ) done ;; + darwin*) + tmp=( "${(@f)$(/sbin/mount)}" ) + dev_tmp=( "${(@)${(@)tmp%% *}:#map}" ) + mp_tmp=( "${(@)${(@)tmp#* on }%% \(*}" ) + ;; *) /sbin/mount | while read mline; do mp_tmp+=( $mline[(w)1] ) diff --git a/Completion/Unix/Command/_quilt b/Completion/Unix/Command/_quilt index 130f38149..2ceb2ffaa 100644 --- a/Completion/Unix/Command/_quilt +++ b/Completion/Unix/Command/_quilt @@ -32,8 +32,8 @@ _arguments \ '--quiltrc[Use the specified configuration file]:files:_files' \ '--version[Print the version number and exit]' \ ':quilt command:(add annotate applied delete diff edit files fold fork graph - grep header import mail new next patches pop previous push refresh rename - revert series setup shell snapshot top unapplied upgrade)' \ + grep header import mail new next patches pop previous push refresh remove + rename revert series setup snapshot top unapplied upgrade)' \ '*::subcmd:->subcmd' && return 0 case "$state" in (subcmd) @@ -109,6 +109,9 @@ case "$state" in (subcmd) '-T ps[Directly produce a PostScript output file]' \ ':quilt series:_quilt_series' ;; + (grep) + _arguments '-h' + ;; (header) _arguments '-h' \ '-a[Append the exiting patch header]' \ @@ -131,6 +134,7 @@ case "$state" in (subcmd) (mail) _arguments '-h' \ '-m[Text to use as the text in the introduction]:quilt select text: ' \ + '-M[Like the -m option, but read the introduction from file]:files:_files' \ '--prefix[Use an alternate prefix in the bracketed part of the subjects generated]:quilt select prefix: ' \ '--mbox[Store all messages in the specified file in mbox format]:files:_files' \ '--send[Send the messages directly]' \ @@ -145,7 +149,8 @@ case "$state" in (subcmd) '*:quilt series:_quilt_series' ;; (new) - _arguments '-h' + _arguments '-h' \ + '-p[Select a patch style]:quilt patch style:(0 1 ab)' ;; (next) _arguments '-h' \ @@ -175,6 +180,8 @@ case "$state" in (subcmd) '-q[Quiet operation]' \ '-f[Force apply, even if the patch has rejects]' \ '-v[Verbose operation]' \ + '--fuzz[Set the maximum fuzz factor]' \ + '--merge=[Merge the patch file into the original files]:quilt select merge:(merge diff3)' \ '--leave-rejects[Leave around the reject files patch produced]' \ '--color=[Use syntax coloring]:quilt select color:(always auto never)' \ ':quilt unapplied:_quilt_unapplied' @@ -196,6 +203,10 @@ case "$state" in (subcmd) '--strip-trailing-whitespace[Strip trailing whitespace at the end of lines]' \ ':quilt series:_quilt_series' ;; + (remove) + _arguments '-h' \ + '-P[Patch to remove]:quilt series:_quilt_series' + ;; (rename) _arguments '-h' \ '-P[Patch to rename]:quilt series:_quilt_series' @@ -214,12 +225,9 @@ case "$state" in (subcmd) '-d[Optional path prefix for the resulting source tree]:quilt select path-prefix: ' \ '--sourcedir[Directory that contains the package sources]:quilt select package sources directory: ' \ '-v[Verbose debug output]' \ + '--fuzz[Set the maximum fuzz factor]' \ ':files:_files' ;; - (shell) - _arguments '-h' \ - ':quilt select shell command:_command_names -e' - ;; (snapshot) _arguments '-h' \ '-d[Remove current snapshot]' diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh index 8f1fb74aa..7e85e2bb6 100644 --- a/Completion/Unix/Command/_ssh +++ b/Completion/Unix/Command/_ssh @@ -1,6 +1,6 @@ -#compdef ssh slogin=ssh scp ssh-add ssh-agent ssh-keygen sftp +#compdef ssh slogin=ssh scp ssh-add ssh-agent ssh-keygen sftp ssh-copy-id -# Completions currently based on OpenSSH 5.9 (released on 2011-09-06). +# Completions currently based on OpenSSH 6.0 (released on 2012-04-22). # # TODO: update ssh-keygen (not based on 5.9) # TODO: sshd, ssh-keyscan, ssh-keysign @@ -18,7 +18,7 @@ _ssh () { # for protocol version 2, this can be a comma-separated list '-c+[select encryption cipher]:encryption cipher:(idea des 3des blowfish arcfour tss none)' '-F+[specify alternate config file]:config file:_files' - '-i+[select identity file]:SSH identity file:_files' + '*-i+[select identity file]:SSH identity file:_files' '*-o+[specify extra options]:option string:->option' ) common_transfer=( @@ -50,7 +50,7 @@ _ssh () { '(-1)-m+[specify mac algorithms]:mac spec:->macs' \ '(-1)-N[do not execute a remote command (protocol version 2 only)]' \ '-n[redirect stdin from /dev/null]' \ - '-O:multiplex control command:((check\:"check master process is running" exit\:"request the master to exit" forward\:"request forward without command execution" stop\:"request the master to stop accepting further multiplexing requests"))' \ + '-O:multiplex control command:((check\:"check master process is running" exit\:"request the master to exit" forward\:"request forward without command execution" stop\:"request the master to stop accepting further multiplexing requests" cancel\:"cancel existing forwardings with -L and/or -R"))' \ '-P[use non privileged port]' \ '-p+[specify port on remote host]:port number on remote host' \ '(-v)*-q[quiet operation]' \ @@ -133,6 +133,11 @@ _ssh () { '-s[SSH2 subsystem or path to sftp server on the remote host]' \ '1:file:->rfile' '*:file:->file' "$common[@]" "$common_transfer[@]" && ret=0 ;; + (ssh-copy-id) + _arguments \ + '-i:SSH identity file:_files' \ + ':remote host name:->userhost' \ + ;; esac while [[ -n "$state" ]]; do diff --git a/Completion/Unix/Command/_systemctl b/Completion/Unix/Command/_systemctl deleted file mode 100644 index 3f54092a1..000000000 --- a/Completion/Unix/Command/_systemctl +++ /dev/null @@ -1,311 +0,0 @@ -#compdef systemctl - -# Copyright (c) 2011 Foudil Brétel <foudil.newbie+zshsystemctl@gmail.com> -# -# This file is released under the GPLv3. -# -# inspired from _yum and systemctl-bash-completion.sh (shipped with systemctl) -# -# TODO: enable options after commands. Ex: systemctl list-units --all --full - -# Main dispatcher -_systemctl() -{ - local curcontext="$curcontext" state lstate line - - # -s for aggregated options like -aP - _arguments -s \ - {-h,--help}'[Show help]' \ - '--version[Show package version]' \ - {-t,--type=}'[List only units of a particular type]:unit type:(automount device mount path service snapshot socket swap target timer)' \ - \*{-p,--property=}'[Show only properties by specific name]:unit property:' \ - {-a,--all}'[Show all units/properties, including dead/empty ones]' \ - '--failed[Show only failed units]' \ - "--full[Don't ellipsize unit names on output]" \ - '--fail[When queueing a new job, fail if conflicting jobs are pending]' \ - '--ignore-dependencies[When queueing a new job, ignore all its dependencies]' \ - '--kill-mode=[How to send signal]:killmode:(control-group process)' \ - '--kill-who=[Who to send signal to]:killwho:(main control all)' \ - {-s,--signal=}'[Which signal to send]:signal:_signals' \ - {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \ - {-P,--privileged}'[Acquire privileges before execution]' \ - {-q,--quiet}'[Suppress output]' \ - '--no-block[Do not wait until operation finished]' \ - "--no-wall[Don't send wall message before halt/power-off/reboot]" \ - "--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \ - '--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \ - '--no-pager[Do not pipe output into a pager]' \ - '--no-ask-password[Do not ask for system passwords]' \ - '--order[When generating graph for dot, show only order]' \ - '--require[When generating graph for dot, show only requirement]' \ - '--system[Connect to system manager]' \ - '--user[Connect to user service manager]' \ - '--global[Enable/disable unit files globally]' \ - {-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \ - '--defaults[When disabling unit files, remove default symlinks only]' \ - '--root=[Enable unit files in the specified root directory]:directory:_directories' \ - '*::systemctl command:_systemctl_command' -} - -_hosts_or_user_at_host() -{ - _alternative \ - 'users-hosts:: _user_at_host' \ - 'hosts:: _hosts' -} - -(( $+functions[_systemctl_command] )) || _systemctl_command() -{ - local -a _systemctl_cmds - _systemctl_cmds=( - "list-units:List units" - "start:Start (activate) one or more units" - "stop:Stop (deactivate) one or more units" - "reload:Reload one or more units" - "restart:Start or restart one or more units" - "condrestart:Restart one or more units if active" - "try-restart:Restart one or more units if active" - "reload-or-restart:Reload one or more units is possible, otherwise start or restart" - "force-reload:Reload one or more units is possible, otherwise restart if active" - "reload-or-try-restart:Reload one or more units is possible, otherwise restart if active" - "isolate:Start one unit and stop all others" - "kill:Send signal to processes of a unit" - "is-active:Check whether units are active" - "status:Show runtime status of one or more units" - "show:Show properties of one or more units/jobs or the manager" - "reset-failed:Reset failed state for all, one, or more units" - "list-unit-files:List installed unit files" - "enable:Enable one or more unit files" - "disable:Disable one or more unit files" - "preset:Enable/disable one or more unit files based on preset configuration" - "mask:Mask one or more units" - "unmask:Unmask one or more units" - "link:Link one or more units into the search path" - "is-enabled:Check whether unit files are enabled" - "load:Load one or more units" - "list-jobs:List jobs" - "cancel:Cancel all, one, or more jobs" - "monitor:Monitor unit/job changes" - "dump:Dump server status" - "dot:Dump dependency graph for dot(1)" - "snapshot:Create a snapshot" - "delete:Remove one or more snapshots" - "daemon-reload:Reload systemd manager configuration" - "daemon-reexec:Reexecute systemd manager" - "show-environment:Dump environment" - "set-environment:Set one or more environment variables" - "unset-environment:Unset one or more environment variables" - "default:Enter system default mode" - "rescue:Enter system rescue mode" - "emergency:Enter system emergency mode" - "halt:Shut down and halt the system" - "poweroff:Shut down and power-off the system" - "reboot:Shut down and reboot the system" - "kexec:Shut down and reboot the system with kexec" - "exit:Ask for user instance termination" - ) - - if (( CURRENT == 1 )); then - _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@" - else - local curcontext="$curcontext" - - cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}" - # Deal with any aliases - case $cmd in - condrestart) cmd="try-restart";; - force-reload) cmd="reload-or-try-restart";; - esac - - if (( $#cmd )); then - curcontext="${curcontext%:*:*}:systemctl-${cmd}:" - - local update_policy - zstyle -s ":completion:${curcontext}:" cache-policy update_policy - if [[ -z "$update_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy - fi - - _call_function ret _systemctl_$cmd || _message 'no more arguments' - else - _message "unknown systemctl command: $words[1]" - fi - return ret - fi -} - -__check_option_nolegend() -{ - systemctl --no-legend --version 2>&1 | grep -q 'unrecognized option' - print -Pn '%(?..--no-legend)' -} -nolegend=$(__check_option_nolegend) - - -# Fills the unit lists -_systemctl_all_units() -{ - if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) && - ! _retrieve_cache SYS_ALL_UNITS; - then - _sys_all_units=( $(systemctl ${nolegend} list-units --full --all \ - | cut -d' ' -f1 2>/dev/null) ) - _store_cache SYS_ALL_UNITS _sys_all_units - fi -} - -_systemctl_inactive_units() -{ - _sys_inactive_units=( $(systemctl ${nolegend} list-units --full --all \ - | awk '$3 != "active" {print $1}' 2>/dev/null) ) -} - -_systemctl_active_units() -{ - _sys_active_units=( $(systemctl ${nolegend} list-units --full \ - | cut -d' ' -f1 2>/dev/null) ) -} - -_systemctl_failed_units() -{ - _sys_failed_units=( $(systemctl ${nolegend} list-units --full --failed \ - | cut -d' ' -f1 2>/dev/null) ) -} - -_filter_units_by_property () { - local property=$1 value=$2 ; shift ; shift - local -a units ; units=($*) - local -a props ; props=( $(systemctl show --property "$property" -- \ - ${units[*]} | grep -v '^$') ) - for ((i=1; $i <= ${#units[*]}; i++)); do - if [[ "${props[i]}" = "$property=$value" ]]; then - echo "${units[i]}" - fi - done -} - -# Completion functions for ALL_UNITS -for fun in enable disable is-active is-enabled status show ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - _systemctl_all_units - compadd "$@" -a - _sys_all_units - } -done - -# Completion functions for STARTABLE_UNITS -(( $+functions[_systemctl_start] )) || _systemctl_start() -{ - _systemctl_inactive_units - compadd "$@" - $( _filter_units_by_property CanStart yes \ - ${_sys_inactive_units[*]} | grep -Ev '\.(device|snapshot)$' ) -} - -# Completion functions for RESTARTABLE_UNITS -for fun in restart reload-or-restart ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - _systemctl_all_units - compadd "$@" - $( _filter_units_by_property CanStart yes \ - ${_sys_all_units[*]} | grep -Ev '\.(device|snapshot|socket|timer)$' ) - } -done - -# Completion functions for STOPPABLE_UNITS -for fun in stop kill try-restart condrestart ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - _systemctl_active_units - compadd "$@" - $( _filter_units_by_property CanStop yes \ - ${_sys_active_units[*]} ) - } -done - -# Completion functions for RELOADABLE_UNITS -for fun in reload reload-or-try-restart force-reload ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - _systemctl_active_units - compadd "$@" - $( _filter_units_by_property CanReload yes \ - ${_sys_active_units[*]} ) - } -done - -# Completion functions for ISOLATABLE_UNITS -(( $+functions[_systemctl_isolate] )) || _systemctl_isolate() -{ - _systemctl_all_units - compadd "$@" - $( _filter_units_by_property AllowIsolate yes \ - ${_sys_all_units[*]} ) -} - -# Completion functions for FAILED_UNITS -(( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed() -{ - _systemctl_failed_units - compadd "$@" -a - _sys_failed_units || _message "no failed-unit found" -} - -# Completion functions for JOBS -(( $+functions[_systemctl_cancel] )) || _systemctl_cancel() -{ - compadd "$@" - $(systemctl ${nolegend} list-jobs \ - | cut -d' ' -f1 2>/dev/null ) || _message "no job found" -} - -# Completion functions for SNAPSHOTS -(( $+functions[_systemctl_delete] )) || _systemctl_delete() -{ - compadd "$@" - $(systemctl ${nolegend} list-units --type snapshot --full \ - --all | cut -d' ' -f1 2>/dev/null ) || _message "no snampshot found" -} - -# Completion functions for ENVS -for fun in set-environment unset-environment ; do - (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() - { - local fun=$0 ; fun=${fun##_systemctl_} - local suf - if [[ "${fun}" = "set-environment" ]]; then - suf='-S=' - fi - - compadd "$@" ${suf} - $(systemctl show-environment \ - | sed 's_\([^=]\+\)=.*_\1_' ) - } -done - -# no completion for: -# [STANDALONE]='daemon-reexec daemon-reload default dot dump emergency exit -# halt kexec list-jobs list-units monitor poweroff reboot -# rescue show-environment' -# [NAME]='snapshot load' - -_systemctl_caching_policy() -{ - local _sysunits - local -a oldcache - - # rebuild if cache is more than a day old - oldcache=( "$1"(mh+1) ) - (( $#oldcache )) && return 0 - - _sysunits=($(systemctl ${nolegend} --full --all | cut -d' ' -f1)) - - if (( $#_sysunits )); then - for unit in $_sysunits; do - [[ "$unit" -nt "$1" ]] && return 0 - done - fi - - return 1 -} - -_systemctl "$@" - -# Local Variables: -# mode: sh -# sh-indentation: 2 -# indent-tabs-mode: nil -# sh-basic-offset: 2 -# End: diff --git a/Completion/Unix/Command/_systemd b/Completion/Unix/Command/_systemd new file mode 100644 index 000000000..585ed9c41 --- /dev/null +++ b/Completion/Unix/Command/_systemd @@ -0,0 +1,459 @@ +#compdef systemctl systemd-loginctl + +# Copyright (c) 2011 Foudil Brétel <foudil.newbie+zshsystemctl@gmail.com> +# +# This file is released under the GPLv3. +# +# inspired from _yum and systemctl-bash-completion.sh (shipped with systemctl) +# +# TODO: enable options after commands. Ex: systemctl list-units --all --full + +# Main dispatcher +_systemd() +{ + local curcontext="$curcontext" state lstate line + + case "$service" in + systemctl) + # -s for aggregated options like -aP + _arguments -s \ + {-h,--help}'[Show help]' \ + '--version[Show package version]' \ + {-t,--type=}'[List only units of a particular type]:unit type:(automount device mount path service snapshot socket swap target timer)' \ + \*{-p,--property=}'[Show only properties by specific name]:unit property:()' \ + {-a,--all}'[Show all units/properties, including dead/empty ones]' \ + '--failed[Show only failed units]' \ + "--full[Don't ellipsize unit names on output]" \ + '--fail[When queueing a new job, fail if conflicting jobs are pending]' \ + '--ignore-dependencies[When queueing a new job, ignore all its dependencies]' \ + '--kill-mode=[How to send signal]:killmode:(control-group process)' \ + '--kill-who=[Who to send signal to]:killwho:(main control all)' \ + {-s,--signal=}'[Which signal to send]:signal:_signals' \ + {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \ + {-P,--privileged}'[Acquire privileges before execution]' \ + {-q,--quiet}'[Suppress output]' \ + '--no-block[Do not wait until operation finished]' \ + "--no-wall[Don't send wall message before halt/power-off/reboot]" \ + "--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \ + '--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \ + '--no-pager[Do not pipe output into a pager]' \ + '--no-ask-password[Do not ask for system passwords]' \ + '--order[When generating graph for dot, show only order]' \ + '--require[When generating graph for dot, show only requirement]' \ + '--system[Connect to system manager]' \ + '--user[Connect to user service manager]' \ + '--global[Enable/disable unit files globally]' \ + {-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \ + '--root=[Enable unit files in the specified root directory]:directory:_directories' \ + '--runtime[Enable unit files only temporarily until next reboot]' \ + '*::systemctl command:_systemctl_command' + ;; + + systemd-loginctl) + _arguments -s \ + {-h,--help}'[Show help]' \ + '--version[Show package version]' \ + \*{-p,--property=}'[Show only properties by this name]:unit property:' \ + {-a,--all}'[Show all properties, including empty ones]' \ + '--failed[Show only failed units]' \ + '--kill-who=[Who to send signal to]:killwho:(main control all)' \ + {-s,--signal=}'[Which signal to send]:signal:_signals' \ + {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \ + {-P,--privileged}'[Acquire privileges before execution]' \ + '--no-pager[Do not pipe output into a pager]' \ + '*::systemd-loginctl command:_systemd_loginctl_command' + ;; + + *) _message 'eh?' ;; + esac + +} + +_hosts_or_user_at_host() +{ + _alternative \ + 'users-hosts:: _user_at_host' \ + 'hosts:: _hosts' +} + +(( $+functions[_systemctl_command] )) || _systemctl_command() +{ + local -a _systemctl_cmds + _systemctl_cmds=( + "list-units:List units" + "start:Start (activate) one or more units" + "stop:Stop (deactivate) one or more units" + "reload:Reload one or more units" + "restart:Start or restart one or more units" + "condrestart:Restart one or more units if active" + "try-restart:Restart one or more units if active" + "reload-or-restart:Reload one or more units is possible, otherwise start or restart" + "force-reload:Reload one or more units is possible, otherwise restart if active" + "reload-or-try-restart:Reload one or more units is possible, otherwise restart if active" + "isolate:Start one unit and stop all others" + "kill:Send signal to processes of a unit" + "is-active:Check whether units are active" + "status:Show runtime status of one or more units" + "show:Show properties of one or more units/jobs or the manager" + "reset-failed:Reset failed state for all, one, or more units" + "load:Load one or more units" + "list-unit-files:List installed unit files" + "enable:Enable one or more unit files" + "disable:Disable one or more unit files" + "reenable:Reenable one or more unit files" + "preset:Enable/disable one or more unit files based on preset configuration" + "mask:Mask one or more units" + "unmask:Unmask one or more units" + "link:Link one or more units files into the search path" + "is-enabled:Check whether unit files are enabled" + "list-jobs:List jobs" + "cancel:Cancel all, one, or more jobs" + "dump:Dump server status" + "dot:Dump dependency graph for dot(1)" + "snapshot:Create a snapshot" + "delete:Remove one or more snapshots" + "show-environment:Dump environment" + "set-environment:Set one or more environment variables" + "unset-environment:Unset one or more environment variables" + "daemon-reload:Reload systemd manager configuration" + "daemon-reexec:Reexecute systemd manager" + "default:Enter system default mode" + "rescue:Enter system rescue mode" + "emergency:Enter system emergency mode" + "halt:Shut down and halt the system" + "poweroff:Shut down and power-off the system" + "reboot:Shut down and reboot the system" + "kexec:Shut down and reboot the system with kexec" + "exit:Ask for user instance termination" + ) + + if (( CURRENT == 1 )); then + _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@" + else + local curcontext="$curcontext" + + cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}" + # Deal with any aliases + case $cmd in + condrestart) cmd="try-restart";; + force-reload) cmd="reload-or-try-restart";; + esac + + if (( $#cmd )); then + curcontext="${curcontext%:*:*}:systemctl-${cmd}:" + + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy + fi + + _call_function ret _systemctl_$cmd || _message 'no more arguments' + else + _message "unknown systemctl command: $words[1]" + fi + return ret + fi +} + +__systemctl() +{ + systemctl --full --no-legend --no-pager "$@" +} + + +# Fills the unit list +_systemctl_all_units() +{ + if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) && + ! _retrieve_cache SYS_ALL_UNITS; + then + _sys_all_units=( $(__systemctl list-units --all | { while read a b; do echo "$a"; done; }) ) + _store_cache SYS_ALL_UNITS _sys_all_units + fi +} + +# Fills the unit list including all file units +_systemctl_really_all_units() +{ + local -a all_unit_files; + local -a really_all_units; + if ( [[ ${+_sys_really_all_units} -eq 0 ]] || _cache_invalid SYS_REALLY_ALL_UNITS ) && + ! _retrieve_cache SYS_REALLY_ALL_UNITS; + then + all_unit_files=( $(__systemctl list-unit-files | { while read a b; do echo "$a"; done; }) ) + _systemctl_all_units + really_all_units=($_sys_all_units $all_unit_files) + _sys_really_all_units=(${(u)really_all_units}) + _store_cache SYS_REALLY_ALL_UNITS _sys_really_all_units + fi +} + +_filter_units_by_property() { + local property=$1 value=$2 ; shift ; shift + local -a units ; units=($*) + local prop unit + for ((i=1; $i <= ${#units[*]}; i++)); do + # FIXME: "Failed to issue method call: Unknown unit" errors are ignored for + # now (related to DBUS_ERROR_UNKNOWN_OBJECT). in the future, we need to + # revert to calling 'systemctl show' once for all units, which is way + # faster + unit=${units[i]} + prop=$(systemctl show --no-pager --property="$property" ${unit} 2>/dev/null) + if [[ "${prop}" = "$property=$value" ]]; then + echo "${unit}" + fi + done +} + +_systemctl_active_units() {_sys_active_units=( $(__systemctl list-units | { while read a b; do echo "$a"; done; }) )} +_systemctl_inactive_units(){_sys_inactive_units=($(__systemctl list-units --all | { while read a b c d; do [[ $c == "inactive" ]] && echo "$a"; done; }) )} +_systemctl_failed_units() {_sys_failed_units=( $(__systemctl list-units --failed | { while read a b; do echo "$a"; done; }) )} +_systemctl_enabled_units() {_sys_enabled_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "enabled" ]] && echo "$a"; done; }) )} +_systemctl_disabled_units(){_sys_disabled_units=($(__systemctl list-unit-files | { while read a b; do [[ $b == "disabled" ]] && echo "$a"; done; }) )} +_systemctl_masked_units() {_sys_masked_units=( $(__systemctl list-unit-files | { while read a b; do [[ $b == "masked" ]] && echo "$a"; done; }) )} + +# Completion functions for ALL_UNITS +for fun in is-active is-enabled status show mask preset ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _systemctl_really_all_units + compadd "$@" -a - _sys_really_all_units + } +done + +# Completion functions for ENABLED_UNITS +for fun in disable reenable ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _systemctl_enabled_units + compadd "$@" -a - _sys_enabled_units + } +done + +# Completion functions for DISABLED_UNITS +(( $+functions[_systemctl_enable] )) || _systemctl_enable() +{ + _systemctl_disabled_units + compadd "$@" -a - _sys_disabled_units +} + +# Completion functions for FAILED_UNITS +(( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed() +{ + _systemctl_failed_units + compadd "$@" -a - _sys_failed_units || _message "no failed unit found" +} + +# Completion functions for STARTABLE_UNITS +(( $+functions[_systemctl_start] )) || _systemctl_start() +{ + _systemctl_inactive_units + compadd "$@" -a - _sys_inactive_units +} + +# Completion functions for STOPPABLE_UNITS +for fun in stop kill try-restart condrestart ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _systemctl_active_units + compadd "$@" - $( _filter_units_by_property CanStop yes \ + ${_sys_active_units[*]} ) + } +done + +# Completion functions for ISOLATABLE_UNITS +(( $+functions[_systemctl_isolate] )) || _systemctl_isolate() +{ + _systemctl_all_units + compadd "$@" - $( _filter_units_by_property AllowIsolate yes \ + ${_sys_all_units[*]} ) +} + +# Completion functions for RELOADABLE_UNITS +for fun in reload reload-or-try-restart force-reload ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _systemctl_active_units + compadd "$@" - $( _filter_units_by_property CanReload yes \ + ${_sys_active_units[*]} ) + } +done + +# Completion functions for RESTARTABLE_UNITS +for fun in restart reload-or-restart ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _systemctl_all_units + compadd "$@" - $( _filter_units_by_property CanStart yes \ + ${_sys_all_units[*]} | while read line; do \ + [[ "$line" =~ \.(device|snapshot|socket|timer)$ ]] || echo "$line"; \ + done ) + } +done + +# Completion functions for MASKED_UNITS +(( $+functions[_systemctl_unmask] )) || _systemctl_unmask() +{ + _systemctl_masked_units + compadd "$@" -a - _sys_masked_units || _message "no masked unit found" +} + +# Completion functions for JOBS +(( $+functions[_systemctl_cancel] )) || _systemctl_cancel() +{ + compadd "$@" - $(__systemctl list-jobs \ + | cut -d' ' -f1 2>/dev/null ) || _message "no job found" +} + +# Completion functions for SNAPSHOTS +(( $+functions[_systemctl_delete] )) || _systemctl_delete() +{ + compadd "$@" - $(__systemctl list-units --type snapshot --all \ + | cut -d' ' -f1 2>/dev/null ) || _message "no snampshot found" +} + +# Completion functions for ENVS +for fun in set-environment unset-environment ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + local fun=$0 ; fun=${fun##_systemctl_} + local suf + if [[ "${fun}" = "set-environment" ]]; then + suf='-S=' + fi + + compadd "$@" ${suf} - $(systemctl show-environment \ + | while read line; do echo "${line%%\=}";done ) + } +done + +(( $+functions[_systemctl_link] )) || _systemctl_link() { _files } + +# no systemctl completion for: +# [STANDALONE]='daemon-reexec daemon-reload default dot dump +# emergency exit halt kexec list-jobs list-units +# list-unit-files poweroff reboot rescue show-environment' +# [NAME]='snapshot load' + +_systemctl_caching_policy() +{ + local _sysunits + local -a oldcache + + # rebuild if cache is more than a day old + oldcache=( "$1"(mh+1) ) + (( $#oldcache )) && return 0 + + _sysunits=($(__systemctl --all | cut -d' ' -f1)) + + if (( $#_sysunits )); then + for unit in $_sysunits; do + [[ "$unit" -nt "$1" ]] && return 0 + done + fi + + return 1 +} + + + +_systemd_loginctl_all_sessions(){_sys_all_sessions=($(systemd-loginctl list-sessions | { while read a b; do echo "$a"; done; }) )} +_systemd_loginctl_all_users() {_sys_all_users=( $(systemd-loginctl list-users | { while read a b; do echo "$a"; done; }) )} +_systemd_loginctl_all_seats() {_sys_all_seats=( $(systemd-loginctl list-seats | { while read a b; do echo "$a"; done; }) )} + +# Completion functions for SESSIONS +for fun in session-status show-session activate lock-session unlock-session terminate-session kill-session ; do + (( $+functions[_systemd_loginctl_$fun] )) || _systemd_loginctl_$fun() + { + _systemd_loginctl_all_sessions + compadd "$@" -a - _sys_all_sessions + } +done + +# Completion functions for USERS +for fun in user-status show-user enable-linger disable-linger terminate-user kill-user ; do + (( $+functions[_systemd_loginctl_$fun] )) || _systemd_loginctl_$fun() + { + _systemd_loginctl_all_users + compadd "$@" -a - _sys_all_users + } +done + +# Completion functions for SEATS +(( $+functions[_systemd_loginctl_seats] )) || _systemd_loginctl_seats() +{ + _systemd_loginctl_all_seats + compadd "$@" -a - _sys_all_seats +} +for fun in seat-status show-seat terminate-seat ; do + (( $+functions[_systemd_loginctl_$fun] )) || _systemd_loginctl_$fun() + { _systemd_loginctl_seats } +done + +# Completion functions for ATTACH +(( $+functions[_systemd_loginctl_attach] )) || _systemd_loginctl_attach() +{ + _systemd_loginctl_all_seats + + _arguments -w -C -S -s \ + ':seat:_systemd_loginctl_seats' \ + '*:device:_files' +} + +# no systemd-loginctl completion for: +# [STANDALONE]='list-sessions list-users list-seats flush-devices' + +(( $+functions[_systemd_loginctl_command] )) || _systemd_loginctl_command() +{ + local -a _systemd_loginctl_cmds + _systemd_loginctl_cmds=( + "list-sessions:List sessions" + "session-status:Show session status" + "show-session:Show properties of one or more sessions" + "activate:Activate a session" + "lock-session:Screen lock one or more sessions" + "unlock-session:Screen unlock one or more sessions" + "terminate-session:Terminate one or more sessions" + "kill-session:Send signal to processes of a session" + "list-users:List users" + "user-status:Show user status" + "show-user:Show properties of one or more users" + "enable-linger:Enable linger state of one or more users" + "disable-linger:Disable linger state of one or more users" + "terminate-user:Terminate all sessions of one or more users" + "kill-user:Send signal to processes of a user" + "list-seats:List seats" + "seat-status:Show seat status" + "show-seat:Show properties of one or more seats" + "attach:Attach one or more devices to a seat" + "flush-devices:Flush all device associations" + "terminate-seat:Terminate all sessions on one or more seats" + ) + + if (( CURRENT == 1 )); then + _describe -t commands 'systemd-loginctl command' _systemd_loginctl_cmds || compadd "$@" + else + local curcontext="$curcontext" + + cmd="${${_systemd_loginctl_cmds[(r)$words[1]:*]%%:*}}" + + if (( $#cmd )); then + curcontext="${curcontext%:*:*}:systemd_loginctl-${cmd}:" + + _call_function ret _systemd_loginctl_$cmd || _message 'no more arguments' + else + _message "unknown systemd-loginctl command: $words[1]" + fi + return ret + fi +} + +_systemd "$@" + +# Local Variables: +# mode: sh +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux index 5fb721960..a8f133295 100644 --- a/Completion/Unix/Command/_tmux +++ b/Completion/Unix/Command/_tmux @@ -572,7 +572,7 @@ function _tmux-new-session() { [[ -n ${tmux_describe} ]] && print "Create a new session" && return local -a args args=( - '-d[attach the new session the current terminal]' + '-d[do not attach new session to current terminal]' '-n[name the initial window]:window name' '-s[name the session]:session name' '-t[specify target session]:sessions:__tmux-sessions' @@ -1097,7 +1097,7 @@ function __tmux-buffers() { local -a bopts; bopts=() fi - buffers=( ${${(f)"$(command tmux list-buffers "${bopts[@]}")"}/:[ $'\t']##/:} ) + buffers=( ${${(f)"$(command tmux 2> /dev/null list-buffers "${bopts[@]}")"}/:[ $'\t']##/:} ) _describe -t buffers 'buffers' buffers } @@ -1105,7 +1105,7 @@ function __tmux-bound-keys() { local expl local -a keys - keys=( ${${${${(f)"$(command tmux list-keys "$@")"}/:[ $'\t']##/:}/(#s)[ $'\t']##/}/(#s):/\\:} ) + keys=( ${${${${(f)"$(command tmux 2> /dev/null list-keys "$@")"}/:[ $'\t']##/:}/(#s)[ $'\t']##/}/(#s):/\\:} ) _describe -t keys 'keys' keys } @@ -1124,7 +1124,7 @@ function __tmux-choose-stuff() { function __tmux-clients() { local expl local -a clients - clients=( ${${(f)"$(command tmux list-clients)"}/:[ $'\t']##/:} ) + clients=( ${${(f)"$(command tmux 2> /dev/null list-clients)"}/:[ $'\t']##/:} ) _describe -t clients 'clients' clients } @@ -1400,7 +1400,7 @@ function __tmux-panes() { opts=( ) fi num=0 - command tmux list-panes "${opts[@]}" | while IFS= read -r line; do + command tmux 2> /dev/null list-panes "${opts[@]}" | while IFS= read -r line; do panes+=( $(( num++ )):${line//:/} ) done _describe -t panes 'panes' panes "$@" @@ -1421,7 +1421,7 @@ function __tmux-server-options() { function __tmux-sessions() { local expl local -a sessions - sessions=( ${${(f)"$(command tmux list-sessions)"}/:[ $'\t']##/:} ) + sessions=( ${${(f)"$(command tmux 2> /dev/null list-sessions)"}/:[ $'\t']##/:} ) _describe -t sessions 'sessions' sessions "$@" } @@ -1479,7 +1479,7 @@ function __tmux-windows() { else opts=( ) fi - wins=( ${${(M)${(f)"$(command tmux list-windows "${opts[@]}")"}:#<->*}/:[ $'\t']##/:} ) + wins=( ${${(M)${(f)"$(command tmux 2> /dev/null list-windows "${opts[@]}")"}:#<->*}/:[ $'\t']##/:} ) _describe -t windows 'windows' wins "$@" if [[ ${IPREFIX} != *: ]]; then _wanted sessions expl 'sessions' __tmux-sessions -S: @@ -1528,6 +1528,18 @@ function _tmux() { if [[ -n ${_tmux_aliasmap[$tmuxcommand]} ]] ; then tmuxcommand="${_tmux_aliasmap[$tmuxcommand]}" fi + if ! (( ${+functions[_tmux-$tmuxcommand]} )); then + local low high + low=$_tmux_commands[(i)$tmuxcommand*] + high=$_tmux_commands[(I)$tmuxcommand*] + if (( low == high )); then + tmuxcommand=${_tmux_commands[low]%%:*} + elif (( low < high )); then + _message -e "Ambiguous command $tmuxcommand" + else + _message -e "Subcommand $tmuxcommand not known" + fi + fi curcontext="${curcontext%:*:*}:tmux-${tmuxcommand}:" _call_function ret _tmux-${tmuxcommand} fi diff --git a/Completion/Unix/Command/_wget b/Completion/Unix/Command/_wget index e54a08b27..51d640d62 100644 --- a/Completion/Unix/Command/_wget +++ b/Completion/Unix/Command/_wget @@ -54,7 +54,7 @@ _arguments -C -s \ '--no-cache[disallow server-cached data]' \ '(--html-extension -E)'{--html-extension,-E}'[save all HTML documents with a .html extension]' \ "--ignore-length[ignore \`Content-Length' header field]" \ - '--header=:string' \ + '*--header=:string' \ '--proxy-user=:user' \ '--proxy-password=:password' \ '--referer=:URL:_urls' \ diff --git a/Completion/Unix/Command/_xmlsoft b/Completion/Unix/Command/_xmlsoft index a1f727442..ed5bfe7f7 100644 --- a/Completion/Unix/Command/_xmlsoft +++ b/Completion/Unix/Command/_xmlsoft @@ -41,8 +41,8 @@ case $service in '--maxparserdepth[increase the maximum parser depth]:depth' \ '--html[input document is an HTML file]' \ '--encoding[the input document character encoding]:encoding:(${encoding[@]})' \ - '--param[pass a parameter,value pair]:name::value (xpath expression)' \ - '--stringparam[pass a parameter]:name::value' \ + '*--param[pass a parameter,value pair]:name::value (xpath expression)' \ + '*--stringparam[pass a parameter]:name::value' \ '--path[provide a set of paths for resources]:paths:_files -/' \ '--nonet[refuse to fetch DTDs or entities over network]' \ '--nowrite[refuse to write to any file or resource]' \ @@ -53,7 +53,7 @@ case $service in '--xincludestyle[do XInclude processing on stylesheets]' \ '--load-trace[print trace of all external entites loaded]' \ {--profile,--norman}'[dump profiling information]' \ - '1:stylesheet:_files -g "*.xsl(-.)"' \ + '1:stylesheet:_files -g "*.xslt#(-.)"' \ ':file:_files -g "*.xml(-.)"' && return ;; xmllint) diff --git a/Completion/Unix/Command/_zfs b/Completion/Unix/Command/_zfs index ff404278a..4cc24a59f 100644 --- a/Completion/Unix/Command/_zfs +++ b/Completion/Unix/Command/_zfs @@ -1,55 +1,100 @@ #compdef zfs +# Synced with the S11U1 build 20 man page _zfs() { local context state line expl typeset -A opt_args - local -a subcmds rw_properties rw_propnames ro_properties + local -a subcmds rw_properties rw_propnames ro_properties create_properties + local -a difffields delegatable_perms subcmds=( "create" "destroy" "clone" "promote" "rename" "snapshot" "rollback" "list" "set" "get" "inherit" "mount" "unmount" "share" "unshare" "send" "receive" "allow" "unallow" - "upgrade" + "upgrade" "userspace" "groupspace" "hold" "holds" "release" + "diff" "key" "help" ) + # TODO: userused@ and groupused@ could have more extensive handling ro_properties=( "name" "type" "creation" "used" "available" "referenced" - "compressratio" "mounted" "origin" + "compressratio" "mounted" "origin" "usedbychildren" + "usedbydataset" "usedbyrefreservation" "usedbysnapshots" + "defer_destroy" "userused@" "userrefs" "groupused@" + "keychangedate" "keystatus" "rekeydate" ) # TODO: Be cleverer about what values can be set. Is there any way to # set the sorting for *size properties to false by default? rw_properties=( - "aclinherit:value:(discard noallow secure passthrough)" - "aclmode:value:(discard groupmask passthrough)" + "aclinherit:value:(discard noallow restricted passthrough passthrough-x)" + "aclmode:value:(discard mask passthrough)" "atime:value:(on off)" - "canmount:value:(on off)" - "checksum:value:(on off fletcher2 fletcher4 sha256)" - "compression:value:(on off lzjb gzip gzip-{1..9})" + "canmount:value:(on off noauto)" + "checksum:value:(on off fletcher2 fletcher4 sha256 sha256+mac)" + "compression:value:(on off lzjb gzip gzip-{1..9} zle)" "copies:value:(1 2 3)" + "dedup:value:(on off verify sha256 sha256,verify)" "devices:value:(on off)" + "encryption:value:(off on aes128-ccm aes-192-ccm aes-256-ccm aes-128-gcm aes-192-gcm aes-256-gcm)" "exec:value:(on off)" - "mountpoint:value:{if [[ -prefix /* ]]; then _path_files -/; else _wanted mountpoints expl 'mountpoint (type \"/\" to start completing paths)' compadd legacy none; fi}" + "groupquota@:value:" # TODO: complete group=size|none + "keysource:value:_zfs_keysource_props" + "logbias:value:(latency throughput)" + "mlslabel:value:(none)" # TODO: list sensitivity labels + "mountpoint:path, 'legacy', or 'none':{if [[ -prefix /* ]]; then _path_files -/; else _wanted mountpoints expl 'mountpoint (type \"/\" to start completing paths)' compadd legacy none; fi}" + "multilevel:value:(on off)" + "nbmand:value:(on off)" + "primarycache:value:(all none metadata)" "quota:number or 'none':{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == quota= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'quota' compadd none; fi}" "readonly:value:(on off)" - "recordsize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K)" - "reservation:value:" # <size>, "none" + "recordsize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M)" + "refquota:number or 'none':{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == refquota= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'refquota' compadd none; fi}" + "refreservation:number or 'none':{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == refreservation= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'refreservation' compadd none; fi}" + "reservation:value:{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == reservation= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'reservation' compadd none; fi}" + "rstchown:value:(on off)" + "secondarycache:value:(all none metadata)" "setuid:value:(on off)" - "shareiscsi:value:(on off)" # or "type=<type>" - "sharenfs:value:(on off)" # or share(1M) options + "shadow:value:" # TODO: complete URI|none + "share:share properties:" + "sharenfs:value:(on off)" + "sharesmb:value:(on off)" "snapdir:value:(hidden visible)" - "version:value:(1 2 current)" - "volblocksize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K)" + "sync:value:(standard always disabled)" + "userquota@:value:" # TODO: complete user=size|none + "version:value:(1 2 3 4 current)" "volsize:value:" # <size> + "vscan:value:(on off)" "xattr:value:(on off)" "zoned:value:(on off)" ) + create_properties=( + $rw_properties + "casesensitivity:value:(sensitive insensitive mixed)" + "normalization:value:(none formC formD formKC formKD)" + "utf8only:value:(on off)" + "volblocksize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M)" + ) + + delegatable_perms=( + "allow" "clone" "create" "destroy" "diff" "hold" "key" + "keychange" "mount" "promote" "receive" "release" "rename" + "rollback" "send" "share" "snapshot" + "groupused" "userused" "userprop" + ${create_properties%%:*} + ) + rw_propnames=( ${rw_properties%%:*} ) + difffields=( + object parent size links linkschange name oldname user group + ctime mtime atime crtime + ) + if [[ $service == "zfs" ]]; then _arguments -C -A "-*" \ - '-\?[help]' \ + '-\?[Help]' \ '*::command:->subcmd' && return 0 if (( CURRENT == 1 )); then @@ -63,124 +108,143 @@ _zfs() { case $service in ("create") _arguments -A "-*" \ - '-p[create parent datasets]' \ - '-o[set initial properties]:property:_values -s , "property" $rw_properties' \ + '-p[Create parent datasets]' \ + '-o[Set initial properties]:property:_values -s , "property" $create_properties' \ - set1 \ - ':filesystem:' \ + ':filesystem:_zfs_dataset -t fs -e "parent dataset"' \ - set2 \ - '-s[create sparse volume]' \ - '-b[set volblocksize]:blocksize:' \ - '-V[set size]:size:' \ - ':volume:' + '-s[Create sparse volume]' \ + '-b[Set volblocksize]:blocksize:' \ + '-V[Set size]:size:' \ + ':volume:_zfs_dataset -t fs -e "parent dataset"' ;; ("destroy") _arguments -A "-*" \ - '-r[recursively destroy all children]' \ - '-R[recursively destroy all dependents]' \ - '-f[force unmounts]' \ - ':filesystem/volume/snapshot:_zfs_dataset' + '-r[Recursively destroy all children]' \ + '-R[Recursively destroy all dependents]' \ + - set1 \ + '-d[delete or mark deferred]' \ + ':snapshot:_zfs_dataset -t snap' \ + - set2 \ + '-f[Force unmounts]' \ + ':filesystem/volume/snapshot:_zfs_dataset -t fs -t vol' ;; ("snapshot") _arguments -A "-*" \ - '-r[recursively snapshot all descendant datasets]' \ + '-r[Recursively snapshot all descendant datasets]' \ + '-o[Set property]:property:_values -s , "property" $create_properties' \ ':filesystem/volume:_zfs_dataset -t fs -t vol -S@' ;; ("rollback") _arguments -A "-*" \ - '-r[recursively destroy more recent snapshots]' \ - '-R[recursively destroy more recent snapshots and clones]' \ - '-f[force unmounts]' \ + '-r[Recursively destroy more recent snapshots]' \ + '-R[Recursively destroy more recent snapshots and clones]' \ + '-f[Force unmounts]' \ ':snapshot:_zfs_dataset -t snap' ;; ("clone") # XXX needs to bail if there are no snapshots _arguments -A "-*" \ - '-p[create parent datasets]' \ + '-p[Create parent datasets]' \ + '-K[Create encryption key]' \ + '-o[Set property]:property:_values -s , "property" $create_properties' \ ':snapshot:_zfs_dataset -t snap' \ - ':filesystem/volume:' + ':filesystem/volume:_zfs_dataset -t fs -e "parent dataset"' ;; ("promote") - # XXX complete only cloned filesystems _arguments \ - ':filesystem:_zfs_dataset -t fs' \ + ':filesystem:_zfs_dataset -t clone' \ ;; ("rename") _arguments -A "-*" \ - - set1 \ - '-p[create parent datasets]' \ - ':filesystem/volume/snapshot:_zfs_dataset' \ - ':filesystem/volume/snapshot:' \ - - set2 \ - '-r[recursively rename snapshots of all descendent datasets]' \ - ':snapshot:_zfs_dataset -t snap' \ - ':snapshot:' + '(-r)-p[Create parent datasets]' \ + '(-p)-r[Recursively rename snapshots of all descendent datasets]' \ + ':dataset:_zfs_dataset -r1' \ + ':dataset:_zfs_dataset -r2' ;; ("list") _arguments -A "-*" \ - '-r[recursively display children]' \ - '-H[scripting mode]' \ - '-o[properties to list]:property:_values -s , "property" $ro_properties $rw_propnames' \ - '*-s[sort key (ascending)]:property:_values "property" $ro_properties $rw_propnames' \ - '*-S[sort key (descending)]:property:_values "property" $ro_properties $rw_propnames' \ - '-t[dataset types to list]:dataset type:_values -s , "dataset type" filesystem snapshot volume' \ - '*:filesystem/volume/snapshot:_zfs_dataset' + '-r[Recursively display children]' \ + '-H[Scripting mode]' \ + '-d[Depth]:value:' \ + '-o[Properties to list]:property:_values -s , "property" $ro_properties $rw_propnames' \ + '*-s[Sort key (ascending)]:property:_values "property" $ro_properties $rw_propnames' \ + '*-S[Sort key (descending)]:property:_values "property" $ro_properties $rw_propnames' \ + '-t[Dataset types to list]:dataset type:_values -s , "dataset type" all filesystem snapshot volume' \ + '*:filesystem/volume/snapshot/path:_zfs_dataset -p' ;; ("set") _arguments \ + '-r[Recursively apply value]' \ ':property:_values -s , "property" $rw_properties' \ '*:filesystem/volume:_zfs_dataset -t fs -t vol' ;; ("get") _arguments -A "-*" \ - "-r[recursively display children's properties]" \ - '-H[scripting mode]' \ - '-p[display numbers exactly]' \ - '-s[specify sources]:source:_values -s , "source" local default inherited temporary none' \ - '-o[specify fields]:field:_values -s , "field" name property value source' \ + "-r[Recursively display children's properties]" \ + '-d[Depth]:value:' \ + '-H[Scripting mode]' \ + '-p[Display numbers exactly]' \ + '-s[Specify sources]:source:_values -s , "source" local default inherited temporary none' \ + '-o[Specify fields]:field:_values -s , "field" name property value source' \ ':property:_values -s , "property" $ro_properties $rw_propnames all' \ '*:filesystem/volume/snapshot:_zfs_dataset' ;; ("inherit") _arguments -A "-*" \ - '-r[recursively inherit property for all children]' \ + '-r[Recursively inherit property for all children]' \ + '-S[Revert to received property value]' \ ':property:_values -s , "property" $ro_properties $rw_properties' \ '*:filesystem/volume:_zfs_dataset -t fs -t vol' ;; + ("userspace"|"groupspace") + _arguments -A "-*" \ + '-n[Print numeric ID]' \ + '-i[Translate SID to POSIX ID]' \ + '-H[Tab-delimited output with no headers]' \ + '-p[Parseable mode]' \ + '-o[Properties to list]:property:_values -s , "property" type name used quota' \ + '*-s[Sort key (ascending)]:property:_values "property" type name used quota' \ + '*-S[Sort key (descending)]:property:_values "property" type name used quota' \ + '-t[Types to list]:type:_values -s , "type" all posixuser smbuser posixgroup smbgroup' \ + '*:filesystem/volume/snapshot:_zfs_dataset' + ;; + ("mount") _arguments -A "-*" \ - '-o[mount options]:mount options:_values -s , "option" {,no}{devices,exec,setuid} ro rw' \ - '-O[overlay mount]' \ - '-v[report mount progress]' \ + '-o[Mount options]:mount options:_values -s , "option" {,no}{devices,exec,setuid} ro rw' \ + '-O[Overlay mount]' \ + '-v[Report mount progress]' \ - set1 \ ':filesystem:_zfs_dataset -t fs' \ - set2 \ - '-a[mount all available ZFS filesystems]' + '-a[Mount all available ZFS filesystems]' ;; ("unmount") _arguments -A "-*" \ - set1 \ - '-f[force unmount]' \ + '-f[Force unmount]' \ ':filesystem:_zfs_dataset -t fs -t mtpt' \ - set2 \ - '-a[unmount all ZFS filesystems]' + '-a[Unmount all ZFS filesystems]' ;; ("share") _arguments -A "-*" \ - set1 \ - '-a[share all available ZFS filesystems]' \ + '-a[Share all available ZFS filesystems]' \ - set2 \ ':filesystem:_zfs_dataset -t fs' ;; @@ -188,45 +252,165 @@ _zfs() { ("unshare") _arguments -A "-*" \ - set1 \ - '-a[unshare all shared ZFS filesystems]' \ + '-a[Unshare all shared ZFS filesystems]' \ - set2 \ - '-F[force unshare]' \ ':filesystem:_zfs_dataset -t fs -t mtpt' ;; ("send") _arguments -A "-*" \ - '-i[generate an incremental stream]:snapshot:_zfs_dataset -t snap' \ + '-b' \ + '-i[Generate an incremental stream]:snapshot:_zfs_dataset -t snap' \ + '-D[Perform dedup processing]' \ + '-p[Send properties]' \ + '-v[Verbose]' \ + - set1 \ + '-I[Generate an incremental stream with intermediary snapshots]:snapshot:_zfs_dataset -t snap' \ + '-R[Generate a replication stream package]' \ + ':snapshot:_zfs_dataset -t snap' \ + - set2 \ + '-c[Create a self-contained stream]' \ + '-r[Generate a recursive stream package]' \ ':snapshot:_zfs_dataset -t snap' ;; ("receive") _arguments -A "-*" \ - '-v[verbose]' \ - '-n[do not receive the stream]' \ - '-F[force a rollback if necessary]' \ + '-v[Verbose]' \ + '-n[Do not receive the stream]' \ + '-F[Force a rollback if necessary]' \ + '-u[Filesystem is not mounted]' \ + '-o[Include property change in the stream]::' \ + '-x[Exclude property change from the stream]:property:' \ - set1 \ ':filesystem/volume/snapshot:_zfs_dataset' \ - set2 \ - '-d[set path prefix]:filesystem:_zfs_dataset -t fs' + '(-e)-d[Set path prefix from stream, excluding only pool name]' \ + '(-d)-e[Set path prefix from stream, using last path element]' \ + '-:filesystem:_zfs_dataset -t fs' ;; - ("allow"|"unallow") - _message "unimplemented zfs subcommand: $service" + ("allow") + _arguments -A "-*" \ + - set1 \ + ':filesystem/volume:_zfs_dataset -t fs -t vol' \ + - set2 \ + '(-g)-u[User]:user:_users' \ + '(-u)-g[Group]:group:_groups' \ + '-l[Allow for named dataset]' \ + '-d[Allow for descendent datasets]' \ + ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ + ':filesystem/volume:_zfs_dataset -t fs -t vol' \ + - set3 \ + '-e[Everyone]' \ + '-l[Allow for named dataset]' \ + '-d[Allow for descendent datasets]' \ + ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ + ':filesystem/volume:_zfs_dataset -t fs -t vol' \ + - set4 \ + '-c[Create-time permissions]' \ + ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ + ':filesystem/volume:_zfs_dataset -t fs -t vol' \ + - set5 \ + '-s[Define or modify permission sets]' \ + ':setname:' \ + ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ + ':filesystem/volume:_zfs_dataset -t fs -t vol' + ;; + + ("unallow") + _arguments -A "-*" \ + '-r[Recursive removal]' \ + - set1 \ + '-s[Remove permissions from or delete a permission set]:permission set:' \ + ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ + ':filesystem/volume:_zfs_dataset -t fs -t vol' \ + - set2 \ + '(-g)-u[User]:user:_users' \ + '(-u)-g[Group]:group:_groups' \ + '-l[Allow for named dataset]' \ + '-d[Allow for descendent datasets]' \ + ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ + ':filesystem/volume:_zfs_dataset -t fs -t vol' \ + - set3 \ + '-e[Everyone]' \ + '-l[Allow for named dataset]' \ + '-d[Allow for descendent datasets]' \ + ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ + ':filesystem/volume:_zfs_dataset -t fs -t vol' \ + - set4 \ + '-c[Create-time permissions]' \ + ':permissions or sets:_values -s , "permission or set" $delegatable_perms' \ + ':filesystem/volume:_zfs_dataset -t fs -t vol' ;; ("upgrade") _arguments -A "-*" \ - set1 \ - '-v[verbose]' \ + '-v[Verbose]' \ - set2 \ - '-a[upgrade all filesystems on all pools]' \ - '-r[upgrade descendent filesystems, too]' \ - '-V[upgrade to specified version]:version:(1 2)' \ + '-a[Upgrade all filesystems on all pools]' \ + '-r[Upgrade descendent filesystems, too]' \ + '-V[Upgrade to specified version]:version:(1 2)' \ - set3 \ - '-r[upgrade descendent filesystems, too]' \ - '-V[upgrade to specified version]:version:(1 2)' \ - ':filesystem:_zfs_dataset -t fs' \ + '-r[Upgrade descendent filesystems, too]' \ + '-V[Upgrade to specified version]:version:(1 2)' \ + ':filesystem:_zfs_dataset -t fs' + ;; + + ("hold") + _arguments -A "-*" \ + '-r[Apply hold recursively]' \ + ':tag:' \ + ':snapshot:_zfs_dataset -t snap' + ;; + + ("holds") + _arguments -A "-*" \ + '-r[List holds recursively]' \ + ':snapshot:_zfs_dataset -t snap' + ;; + + ("release") + _arguments -A "-*" \ + '-r[Release holds recursively]' \ + ':tag:' \ + ':snapshot:_zfs_dataset -t snap' + ;; + + ("diff") + _arguments -A "-*" \ + '-F[Add column for filetype character]' \ + '-H[Parseable output]' \ + '-e[Only show new and changed files]' \ + '*-o[Show fields]:field:_values "field" $difffields' \ + '-t[Add column for ctime]' \ + - set1 \ + ':snapshot:_zfs_dataset -t snap' \ + ':snapshot or filesystem:_zfs_dataset -t snap -t fs' \ + - set2 \ + '-E[Show difference from empty]' \ + ':snapshot or filesystem:_zfs_dataset -t snap -t fs' + ;; + + ("key") + _arguments -A "-*" \ + - set1 \ + '-a[Apply to all datasets in all pools]' \ + '(-u -K -f)-l[Load the encryption key]' \ + '(-l -K)-u[Unload the encryption key]' \ + '(-l -u -f)-K[Create a new data encryption key]' \ + '(-l -K)-f[Unmount the dataset before unloading the encryption key]' \ + '-r[Apply recursively]' \ + ':filesystem or volume:_zfs_dataset -t fs -t vol' \ + - set2 \ + '-c[Change the encryption key]' \ + '-o[Change a property]:property:_zfs_keysource_props' \ + ':filesystem or volume:_zfs_dataset -t fs -t vol' + ;; + + ("help") + compadd property $subcmds $ro_properties ${rw_properties%%:*} ;; (*) diff --git a/Completion/Unix/Command/_zpool b/Completion/Unix/Command/_zpool index 9692121ae..0af2ab32d 100644 --- a/Completion/Unix/Command/_zpool +++ b/Completion/Unix/Command/_zpool @@ -1,41 +1,91 @@ #compdef zpool +# Synced with the S11U1 build 19 man page _zpool() { - local -a subcmds fields + local context state line expl + local -a subcmds fields ro_props rw_props versions create_properties_dataset subcmds=( - create destroy add remove list iostat status online - offline clear attach detach replace scrub import export - upgrade history get set + create destroy add remove list iostat status online + offline clear attach detach replace scrub import export + upgrade history get set split ) - fields=( - name\:"Pool name" size\:"Total size" used\:"Space used" - available\:"Space available" capacity\:"Space used (percentage)" - health\:"Health status" + versions=( + ${${${(M)"${(f)$(zpool upgrade -v)}":#[[:space:]]#<->*}##[[:space:]]}%%[[:space:]]*} ) - properties=( - "bootfs:value:" - "autoreplace:value:(on off)" - "delegation:value:(on off)" + ro_props=( + "all[All properties]" + "allocated[Space allocated]" + "capacity[Space used (percentage)]" + "dedupratio[Deduplication ratio]" + "free[Space unallocated]" + "guid[Unique identifier]" + "health[Health status]" + "size[Total size]" ) - propnames=( ${properties%%:*} ) - - import_properties=( - xattr - copies - shareiscsi - canmount - share - sharenfs - userprop - mount + + rw_props=( + "altroot[Alternate root directory]:value:" + "autoexpand[Automatic pool expansion]:value:(on off)" + "autoreplace[Automatic device replacement]:value:(on off)" + "bootfs[Default bootable dataset]:value:" + "cachefile[Pool configuration cache file location]:value:" + "dedupditto[Threshold for number of copies]:value:" + "delegation[Delegated administration]:value:(on off)" + "failmode[Failure-mode behavior]:value:(wait continue panic)" + "listsnaps[Show snapshots in 'zfs list']:value:(on off)" + "version[Pool version]:version:($versions)" + ) + + fields=( ${ro_props%%:*} ${rw_props%%:*} ) + + create_properties_dataset=( + "aclinherit:value:(discard noallow restricted passthrough passthrough-x)" + "aclmode:value:(discard mask passthrough)" + "atime:value:(on off)" + "canmount:value:(on off noauto)" + "checksum:value:(on off fletcher2 fletcher4 sha256 sha256+mac)" + "compression:value:(on off lzjb gzip gzip-{1..9} zle)" + "copies:value:(1 2 3)" + "dedup:value:(on off verify sha256 sha256,verify)" + "devices:value:(on off)" + "encryption:value:(off on aes128-ccm aes-192-ccm aes-256-ccm aes-128-gcm aes-192-gcm aes-256-gcm)" + "exec:value:(on off)" + "groupquota@:value:" # TODO: complete group=size|none + "keysource:value:_zfs_keysource_props" + "logbias:value:(latency throughput)" + "mlslabel:value:(none)" # TODO: list sensitivity labels + "mountpoint:path, 'legacy', or 'none':{if [[ -prefix /* ]]; then _path_files -/; else _wanted mountpoints expl 'mountpoint (type \"/\" to start completing paths)' compadd legacy none; fi}" + "nbmand:value:(on off)" + "primarycache:value:(all none metadata)" + "quota:number or 'none':{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == quota= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'quota' compadd none; fi}" + "readonly:value:(on off)" + "recordsize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M)" + "refquota:number or 'none':{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == refquota= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'refquota' compadd none; fi}" + "refreservation:number or 'none':{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == refreservation= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'refreservation' compadd none; fi}" + "reservation:value:{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ $PREFIX == reservation= ]]; then _wanted none expl 'number or none' compadd none; else _wanted none expl 'reservation' compadd none; fi}" + "rstchown:value:(on off)" + "secondarycache:value:(all none metadata)" + "setuid:value:(on off)" + "shadow:value:" # TODO: complete URI|none + "share:share properties:" + "sharenfs:value:(on off)" + "sharesmb:value:(on off)" + "snapdir:value:(hidden visible)" + "sync:value:(standard always disabled)" + "userquota@:value:" # TODO: complete user=size|none + "version:value:(1 2 3 4 current)" + "volsize:value:" # <size> + "vscan:value:(on off)" + "xattr:value:(on off)" + "zoned:value:(on off)" ) if [[ $service == "zpool" ]]; then _arguments -C -A "-*" \ - '-\?[help]' \ + '-\?[Help]' \ '*::command:->subcmd' && return 0 if (( CURRENT == 1 )); then @@ -48,7 +98,9 @@ _zpool() { case $service in (clear) - _arguments \ + _arguments -A "-*" \ + '-F[Discard transactions to allow pool opening]' \ + '-n[With -F, check if discarding transactions would work]' \ ':pool name:_zfs_pool' \ '*:virtual device:_files' ;; @@ -56,38 +108,46 @@ _zpool() { (create) # TODO: investigate better vdev handling _arguments -A "-*" \ - '-f[force use of in-use devices]' \ - '-n[display configuration without creating pool]' \ - '-R[use alternate root]:alternate root:_files -/' \ - '-m[set mountpoint for root dataset]:mountpoint:' \ + '-B[Create EFI boot partition on whole disks]' \ + '-o[Set pool property at creation time]:property:_values -s , "property" $rw_props' \ + '-O[Set dataset property at creation time]:property:_values -s , "property" $create_properties_dataset' \ + '-f[Force use of in-use devices]' \ + '-l[Display configuration in /dev/chassis location form]' \ + '-n[Display configuration without creating pool]' \ + '-R[Use alternate root]:alternate root:_files -/' \ + '-m[Set mountpoint for root dataset]:mountpoint:' \ ':pool name:' \ '*:virtual device:_files' ;; (destroy) _arguments -A "-*" \ - '-f[force active datasets to be unmounted]' \ + '-f[Force active datasets to be unmounted]' \ ':pool name:_zfs_pool' ;; (add) _arguments -A "-*" \ - '-f[force use of in-use devices]' \ - '-n[display configuration without modifying pool]' \ + '-f[Force use of in-use devices]' \ + '-l[Display configuration in /dev/chassis location form]' \ + '-n[Display configuration without modifying pool]' \ ':pool name:_zfs_pool' \ '*:virtual device:_files' ;; (list) _arguments \ - '-H[scripted mode]' \ - '-o[fields to list]:field:_values -s , "field" ${^fields/\:/[}\]' \ + '-H[Scripted mode]' \ + '-T[timestamp]:value:(u d)' \ + '-o[Fields to list]:field:_values -s , "field" $fields' \ '::pool name:_zfs_pool' ;; (iostat) _arguments -A "-*" \ - '-v[verbose statistics]' \ + '-l[Display configuration in /dev/chassis location form]' \ + '-T[timestamp]:value:(u d)' \ + '-v[Verbose statistics]' \ '*::pool name:_zfs_pool' \ '::interval:' \ '::count:' @@ -95,20 +155,23 @@ _zpool() { (status) _arguments -A "-*" \ - '-v[verbose information]' \ - '-x[show only unhealthy pools]' \ + '-l[Display configuration in /dev/chassis location form]' \ + '-v[Verbose information]' \ + '-x[Show only unhealthy pools]' \ + '-T[timestamp]:value:(u d)' \ '*::pool name:_zfs_pool' ;; (offline) _arguments -A "-*" \ - '-t[offline until next reboot]' \ + '-t[Offline until next reboot]' \ ':pool name:_zfs_pool' \ '*:virtual device:_files' ;; (online) _arguments \ + '-e[Expand device to use all available space]' \ ':pool name:_zfs_pool' \ '*:virtual device:_files' ;; @@ -116,7 +179,7 @@ _zpool() { (attach) # TODO: first device should choose first from existing. _arguments \ - '-f[force attach, even if in use]' \ + '-f[Force attach, even if in use]' \ ':pool name:_zfs_pool' \ ':virtual device:_files' \ ':virtual device:_files' @@ -130,7 +193,7 @@ _zpool() { (replace) _arguments -A "-*" \ - '-f[force attach, even if in use]' \ + '-f[Force attach, even if in use]' \ ':pool name:_zfs_pool' \ ':virtual device:_files' \ '::virtual device:_files' @@ -138,57 +201,72 @@ _zpool() { (scrub) _arguments -A "-*" \ - '-s[stop scrubbing]' \ + '-s[Stop scrubbing]' \ '*:pool name:_zfs_pool' ;; (export) _arguments -A "-*" \ - '-f[forcefully unmount all datasets]' \ + '-f[Forcefully unmount all datasets]' \ '*:pool name:_zfs_pool' ;; (import) - # TODO: -o should complete options + # TODO: -o should complete mount options, too _arguments -A "-*" \ - '*-d[search for devices or files in directory]:_files -/' \ - '-D[destroyed pools]' \ - '-f[force import]' \ + '-D[Destroyed pools]' \ + '(-d)*-c[Use cache file]:cache file:_files' \ + '(-c)*-d[Search for devices or files in directory]:directory:_files -/' \ + '-f[Force import]' \ + '-l[Display configuration in /dev/chassis location form]' \ + '-m[Ignore missing log devices]' \ + '-R[Alternate root]:alternate root:_files -/' \ + '-o[Set pool or dataset property]:property:_values -s , "property" $create_properties_dataset $rw_props' \ - set1 \ - '-o[mount options]' \ - '-p[set property]:property:_values -s , "property" $import_properties' \ - '-R[alternate root]:_files -/' \ '*:pool name or id:_zfs_pool' \ '::new pool name:' \ - set2 \ - '-a[all pools]' + '-N[Do not mount any filesystems]' \ + '-a[All pools]' ;; (get) _arguments -A "-*" \ - ':property:_values -s , "property" $propnames all' \ + ':property:_values -s , "property" $fields' \ '*:pool name:_zfs_pool' ;; (set) _arguments -A "-*" \ - ':property:_values -s , "property" $properties' \ + ':property:_values -s , "property" $rw_props' \ '*:pool name:_zfs_pool' ;; + (split) + _arguments -A "-*" \ + '-R[Alternate root]:alternate root:_files -/' \ + '-l[Display configuration in /dev/chassis location form]' \ + '-n[Display configuration without splitting]' \ + '-o[Set pool or dataset property]:property:_values -s , "property" $create_properties_dataset $rw_props' \ + ':pool name or id:_zfs_pool' \ + ':new pool name:' \ + '*::virtual device:_files -/' + ;; + (upgrade) _arguments -A "-*" \ - set1 \ - '-v[display ZFS versions and descriptions]' \ + '-v[Display ZFS versions and descriptions]' \ - set2 \ - '-a[upgrade all pools]' \ + "-V[Upgrade to given version]:version:($versions)" \ + '-a[Upgrade all pools]' \ '*:pool name:_zfs_pool' ;; (history) _arguments -A "-*" \ - '-i[display internal events]' \ - '-l[long format]' \ + '-i[Display internal events]' \ + '-l[Long format]' \ '*:pool name:_zfs_pool' ;; |