diff options
Diffstat (limited to 'Completion')
-rw-r--r-- | Completion/Unix/Command/_git | 2 | ||||
-rw-r--r-- | Completion/Unix/Command/_rsync | 10 | ||||
-rw-r--r-- | Completion/Unix/Command/_zstd | 118 | ||||
-rw-r--r-- | Completion/Unix/Type/_remote_files | 20 | ||||
-rw-r--r-- | Completion/X/Command/_setxkbmap | 210 | ||||
-rw-r--r-- | Completion/Zsh/Context/_equal | 10 | ||||
-rw-r--r-- | Completion/Zsh/Type/_module_math_func | 2 |
7 files changed, 267 insertions, 105 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 22b945e38..86b8a7455 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -278,6 +278,7 @@ _git-bisect () { _arguments -C -s \ $log_options \ $revision_options && ret=0 + ;; (*) _nothing ;; @@ -664,7 +665,6 @@ _git-clone () { '(--single-branch)--no-single-branch[clone history leading up to each branch]' \ "--no-tags[don't clone any tags and make later fetches not follow them]" \ '--shallow-submodules[any cloned submodules will be shallow]' \ - '--recursive[initialize all contained submodules]' \ '(--recursive --recurse-submodules)'{--recursive,--recurse-submodules}'=-[initialize submodules in the clone]::file:__git_files' \ '--separate-git-dir[place .git dir outside worktree]:path to .git dir:_path_files -/' \ \*--server-option='[send specified string to the server when using protocol version 2]:option' \ diff --git a/Completion/Unix/Command/_rsync b/Completion/Unix/Command/_rsync index c65266dbd..81d25a3f4 100644 --- a/Completion/Unix/Command/_rsync +++ b/Completion/Unix/Command/_rsync @@ -60,7 +60,14 @@ elif compset -P 1 '*::' || compset -P 1 'rsync://*/'; then elif compset -P 'rsync://'; then _rsync_user_or_host / "$@" elif compset -P 1 '*:'; then - _remote_files -- ssh + if [[ -v opt_args[(i)client---old-args] || $RSYNC_OLD_ARGS = 1 ]]; then + _remote_files -- ssh + else + # the 3.2.4+ way that rsync handles filenames does not protect *, ? and [] + # so those characters still need to be escaped to prevent being treated as + # a pattern in the remote shell. + _remote_files -Q '[][*?]' -- ssh + fi else _rsync_user_or_host : "$@" fi @@ -236,6 +243,7 @@ _rsync() { '*--include=[do not exclude files matching pattern]:pattern' \ '--files-from=[read list of source-file names from specified file]:file:_files' \ '(-0 --from0)'{-0,--from0}'[all *-from file lists are delimited by nulls]' \ + '--old-args[disable the modern arg-protection idiom]' \ '(-s --secluded-args)'{-s,--secluded-args}'[use the protocol to safely send arguments]' \ "--trust-sender[trust the remote sender's file list]" \ '--copy-as=[specify user & optional group for the copy]:user:_rsync_users_groups' \ diff --git a/Completion/Unix/Command/_zstd b/Completion/Unix/Command/_zstd new file mode 100644 index 000000000..92c4a8e41 --- /dev/null +++ b/Completion/Unix/Command/_zstd @@ -0,0 +1,118 @@ +#compdef zstd zstdmt unzstd zstdcat -redirect-,<,unzstd=unzstd -redirect-,>,zstd=unzstd -redirect-,<,zstd=zstd + +local ign +local -a levels implied noopt args blksize + +(( $#words > 2 )) && ign='!' + +[[ $compstate[context] = redirect ]] && noopt=( -- ) +case "$service" in + zstdmt) implied=( -T0 ) ;; + unzstd) (( $words[(I)(-z|--compress)] )) || implied=( -d ) ;; + zstdcat) + implied=( -dcf ) + (( $words[(I)(-z|--compress)] )) && implied=( -cf ) + ;; +esac +words[1]+=( $implied $noopt ) +(( CURRENT += $#implied + $#noopt )) + +if (( $words[(r)--ultra] )); then + levels=( -{20..22} ) +else + levels=( -{1..19} ) +fi + +blksize=( + '(M -B --block-size)'{-B+,--block-size=-}'[cut file into independent blocks of specified size]: :_numbers -d "no block" -u bytes size KiB MiB' +) +if (( $words[(r)--train] )); then + args=( $blksize + '(M)--train-cover=-[use the cover algorithm with optional arguments]::parameter' + '(M)--train-fastcover=-[use the fast cover algorithm with optional arguments]::parameter' + '(M)--train-legacy=-[use the legacy algorithm with selectivity]::selectivity [9]' + '-o[specify dictionary name]:dictionary name [dictionary]' + '(M)--maxdict=[limit dictionary to specified size]: :_numbers -u bytes -d 112640 size KiB MiB' + '(M)--dictID=[force dictionary ID to specified value]:value [random]' + '*:files:_files' + ) +elif (( $words[(I)-b[0-9]#] )); then + args=( $blksize + '(M)-e-[test all compression levels successively from -b level]: :_numbers -d 3 -l 1 -m 19 level' + '(M)-i-[specify minimum evaluation time]: :time (seconds) [3]' + '(M -B --block-size)'{-B+,--block-size=-}'[cut file into independent blocks of specified size]: :_numbers -d "no block" -u bytes size KiB MiB' \ + '(M)-S[output one benchmark result per input file]' + '(M)--priority=-[set process priority]:priority:(rt)' + '*:files:_files -g "^*.(|t)zst(-.)"' + ) +elif (( $words[(I)(-d|--decompress|--uncompress|-l|--list|-t|--test)] )); then + args=( + '(M --sparse -c --stdout)--no-sparse[sparse mode]' + '(M --no-sparse -o)--sparse[sparse mode]' + '(--sparse)-o[specify output file]:file:_files -g "^*.(|t)zst(-.)"' + "(M)--no-check[ignore checksums in compressed frame]" + '!(M --no-check)'{-C,--check} + '*:files:_files -g "*.(|t)zst(-.)"' + ) +else + args=( + "(M)--no-check[don't add/verify XXH64 integrity checksums]" + '!(M --no-check)'{-C,--check} + "(M)--no-content-size[don't include original file size in header]" + '!(M --no-content-size)--content-size' + "(M)--no-progress[don't show the progress bar but keep other messages]" + '!(M --no-progress)--progress' + "(M --adapt --fast --ultra ${levels[*]})"$^levels + '(M --fast)--ultra[enable levels beyond 19, up to 22]' + '--long=-[enable long distance matching with given window log]:window log [27]' + "(M --adapt --ultra ${levels[*]})--fast=-[switch to very fast compression levels]:level [1]" + "(M --fast ${levels[*]})--adapt=-[dynamically adapt compression level to I/O conditions]: :_values -s , 'range' + 'min\:level' '(min)max\:level'" + '(M)'--{no-,}row-match-finder'[force usage of fast row-based matchfinder for greedy, lazy, and lazy2 strategies]' + "(-D)--patch-from=[specify the file to be used as a reference point for zstd's diff engine]: :_files" + '(--single-thread -T --threads)'{-T-,--threads=}'[spawn specified number of threads]:threads [1]' + '(M -B --block-size)'{-B-,--block-size=-}'[select block size of each job]: :_numbers -u bytes -d 0\:automatic "block size" KiB MiB' + '(M -T --threads --rsyncable)--single-thread[use a single thread for both I/O and compression (result different than -T1)]' + '(M)--auto-threads=[use either physical cores or logical cores as default when specifying -T0]:cores [physical]:(physical logcial)' + '(M --single-thread)--rsyncable[compress using a rsync-friendly method]' + '(M)--exclude-compressed[only compress files that are not already compressed]' + '(M --size-hint)--stream-size=-[specify exact size of streaming input from stdin]: :_numbers -u bytes size KiB MiB' + '(M --stream-size)--size-hint=[indicate size of streamed input to optimize compression parameters]: :_numbers -u bytes size KiB MiB' + '(M)--target-compressed-block-size=[generate compressed block of approximately targeted size]: :_numbers -u bytes limit KiB MiB' + "(M)--no-dictID[don't write dictID into header (dictionary compression only)]" + '(M --no-compress-literals --compress-literals)'--{no-,}compress-literals'[force (un)compressed literals]' + '(M)--show-default-cparams[show compression parameters for each file]' + '(--test)-o[specify output file]:file:_files -g "*.(|t)zst(-.)"' + '--format=-[compress files to specified format]:format [zstd]:(zstd gzip xz lzma lz4)' + '--zstd=[specify advanced compression options]: :_values -s , "option" + strategy\:strategy "windowLog\:bits (10-31)" "hashLog\:bits (6-30)" + "chainLog\:bits (6-31)" "searchLog\:searches" "minMatch\:length" + "targetLength\:length" "overlapLog\:size" "ldmHashLog\:size" + "ldmMinMatch\:length" "ldmBucketSizeLog\:size" "ldmHashRateLog\:frequency"' + '*:files:_files -g "^*.(|t)zst(-.)"' + ) +fi + +_arguments -s -S : $args \ + "$ign(- *)"{-h,--help}'[display help message]' \ + "$ign(- *)"{-V,--version}'[display version number]' \ + '(--patch-from)-D[use specified dictionary for compression or decompression]:dictionary' \ + '(-f --force)'{-f,--force}'[force overwrite]' \ + '--rm[remove source file(s) after successful compression or decompression]' \ + '!(-k --keep --rm)'{-k,--keep} \ + '(-c --stdout --no-sparse --test)'{-c,--stdout}'[write on standard output]' \ + '(-M --memory)'{-M-,--memory=}'[set a memory usage limit]: :_numbers -u bytes limit KiB MiB' \ + \*{-v,--verbose}'[display more information]' \ + \*{-q,--quiet}'[suppress messages]' \ + '-r[operate recursively on directories]' \ + '--filelist=[read list of files to operate upon from file]: :_files' \ + '--output-dir-flat=[store processed files in directory]: :_directories' \ + '--output-dir-mirror=[store processed files in directory respecting original structure]: :_directories' \ + '--trace=[log tracing information to file]: :_files' \ + + '(M)' \ + \!{-z,--compress,--uncompress} \ + '(-B --block-size)'{-d,--decompress}'[decompress]' \ + '(-B --block-size)'{-l,--list}'[print information about zstd compressed files]' \ + '(-c --stdout -o --rm -B --block-size)'{-t,--test}'[test compressed file integrity]' \ + '(-c --stdout -D -k --keep --rm)--train=[create a dictionary from a training set of files]' \ + '(-c --stdout -k --keep --rm)-b-[benchmark file(s), using specified compression level]:: :_numbers -d 3 -l 1 -m 19 level' diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_remote_files index 93e1b7f43..15c20e5c1 100644 --- a/Completion/Unix/Type/_remote_files +++ b/Completion/Unix/Type/_remote_files @@ -11,6 +11,8 @@ # - -g: specify a pattern to match against files # p, = and * glob qualifiers supported # - -h: specify the remote host, default is ${IPREFIX%:} +# - -Q: specify a pattern of characters to escape in the returned filenames, +# instead of shell metacharacters that ${(q)name} does # - -W: specify the parent directory to list files from, # default is the home directory # @@ -31,14 +33,14 @@ # There should be coloring based on all the different ls -F classifiers. -local expl rempat remfiles remdispf remdispd args cmd suf ret=1 +local expl rempat remfiles remdispf{,q} remdispd{,q} args cmd suf ret=1 local -a args cmd_args -local glob host dir dirprefix +local glob host dir esc dirprefix if zstyle -T ":completion:${curcontext}:files" remote-access; then # Parse options to _remote_files. Stops at the first "--". - zparseopts -D -E -a args / g:=glob h:=host W:=dir + zparseopts -D -E -a args / g:=glob h:=host W:=dir Q:=esc (( $#host)) && shift host || host="${IPREFIX%:}" args=( ${argv[1,(i)--]} ) @@ -85,6 +87,14 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then remdispf=( ${(M)remdispf:#${~glob[2]}} ) fi + if (( $#esc )); then + remdispfq=(${${remdispf%[*=|]}//(#b)(${~esc[2]})/\\$match[1]}) + remdispdq=(${${remdispd%/}//(#b)(${~esc[2]})/\\$match[1]}) + else + remdispfq=(${(q)remdispf%[*=|]}) + remdispdq=(${(q)remdispd%/}) + fi + local -a autoremove [[ -o autoremoveslash ]] && autoremove=(-r "/ \t\n\-") @@ -92,9 +102,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then while _tags; do while _next_label remote-files expl ${suf:-remote directory}; do [[ -n $suf ]] && - compadd "$args[@]" "$expl[@]" -d remdispf -- ${(q)remdispf%[*=|]} && ret=0 + compadd "$args[@]" "$expl[@]" -d remdispf -- $remdispfq && ret=0 compadd ${suf:+-S/} $autoremove "$args[@]" "$expl[@]" -d remdispd \ - -- ${(q)remdispd%/} && ret=0 + -- $remdispdq && ret=0 done (( ret )) || return 0 done diff --git a/Completion/X/Command/_setxkbmap b/Completion/X/Command/_setxkbmap index 882a6f939..0850d5419 100644 --- a/Completion/X/Command/_setxkbmap +++ b/Completion/X/Command/_setxkbmap @@ -1,101 +1,119 @@ #compdef setxkbmap -# TODO: -# model, option, symbols and types suggestions -# take -layout and -variant into account - -_setxkbmap() { - emulate -L zsh - setopt extendedglob - - # xkb files may be in different places depending on system - local dir sourcedir fullname - local -a searchdirs=(${XDG_DATA_HOME:-~/.local/share} ${(s.:.)XDG_DATA_DIRS:-/usr/lib:/usr/share:/usr/local/lib:/usr/local/share}) - for dir in $searchdirs; do - fullname="$dir/X11/xkb" - if [ -d $fullname ] ; then - sourcedir=$fullname - break - fi - done - [ -d $sourcedir ] || return 1 - - local -a arguments - - arguments=( - '-compat[compatibility map]:compatibility:_setxkbmap_compat' - '-config[configuration file]:configuration:_files' - '-display[display]:display:_x_display' - '-geometry[geometry component]:geometry:_setxkbmap_geometry' - '-model[model name]:model:' - '-option[xkb option]:option:' - '(-)'-print'[print component names]' - '-rules[rules file]:rules:_files' - '-symbols[symbols components]:symbols:' - '(-)'{-help,-h}'[display help message]' - '-synch[force synchronization]' - '-types[types components]:types:' - '(-verbose -v)'{-verbose,-v}'[set verbosity level]:verbosity:(0 1 2 3 4 5 6 7 8 9)' - '*::keyboard:_setxkbmap_dispatcher' +local curcontext="$curcontext" sourcedir layout ret=1 +local -a state state_descr line expl matches suf +local -A opt_args + +_arguments -C \ + '(-)'{-\?,-help}'[display help message]' \ + '-compat[compatibility map]:compatibility:->compatmaps' \ + '-config[configuration file]:configuration:_files' \ + '-device[specify numeric id of the input device]:device:->devices' \ + '-display[display]:display:_x_display' \ + '-geometry[geometry component]:geometry:->geometries' \ + '*-I+[add a directory to be searched for layout or rules files]: :_directories' \ + '-keycodes[specify keycodes component name]:name' \ + '-keymap[specify keymap to load]:keymap' \ + '-layout[specify layout used to choose component names]:layout:->layouts' \ + '-model[specify model used to choose component names]:model:->models' \ + '*-option[add an xkb option]:option:->options' \ + '(-)'-print'[print a complete xkb_keymap description]' \ + '-query[print the current layout settings]' \ + '-rules[specify rules file to use]:rules:->rules' \ + '-symbols[specify symbols component name]:symbol' \ + '-synch[force synchronization]' \ + '-types[types components]:type:->types' \ + '(-verbose -v)'{-verbose,-v}'[set verbosity level]:verbosity:(0 1 2 3 4 5 6 7 8 9)' \ + '(-)-version[display version information]' \ + '-variant[specify layout variant used to choose component name]:variant:->variants' \ + '1:layout:->layouts' \ + '2:variant:->variants' \ + '*:option:->options' && ret=0 + +if [[ -n $state ]]; then + local open='(' close=')' + compquote open close + + layout=${opt_args[-layout]:-$line[1]} + if [[ $state = layouts ]]; then + compset -P '*,' + if compset -P 1 '*\('; then + layout="${${IPREFIX%$open}##*,}" + state=variants state_descr=variant + suf=( -S"$close$compstate[quote] " ) + else + suf=( -S$open -r ",('\" \t\n\-" ) + fi + fi + + _description $state expl $state_descr + if (( $+commands[localectl] )); then + case $state in + layouts) matches=( $(_call_program layouts localectl list-x11-keymap-layouts) ) ;; + models) matches=( $(_call_program layouts localectl list-x11-keymap-models) ) ;; + options) matches=( $(_call_program layouts localectl list-x11-keymap-options) ) ;; + variants) matches=( $(_call_program layouts localectl list-x11-keymap-variants $layout) ) ;; + esac + fi + if (( ! $#matches )); then + sourcedir=$(pkg-config xkeyboard-config --variable=xkb_base 2>/dev/null) + [[ -z $sourcedir ]] && sourcedir=( + ${XDG_DATA_HOME:-~/.local/share}/X11/xkb(N/) + ${(s.:.)XDG_DATA_DIRS:-/usr/lib:/usr/share:/usr/local/lib:/usr/local/share}/X11/xkb(N/) ) - _arguments $arguments -} - -_setxkbmap_dispatcher () { - - case $CURRENT in - 1) - _setxkbmap_layout - ;; - 2) - _setxkbmap_variant "$words[1]" - ;; + (( $#sourcedir )) && case $state in + layouts) matches=( $sourcedir/symbols/**/^README(.Ne."REPLY=\${REPLY#*/symbols/}".) ) ;; + compatmaps) matches=( $sourcedir/compat/^README(.:t) ) ;; + models) matches=( $(sed -n '/modelList/,/\/modelList/ s, *<name>\(.*\)</name>,\1,p' $sourcedir/rules/(evdev|base).xml(.N[1])) ) ;; + options) matches=( $(sed -n '/optionList/,/\/optionList/ s, *<name>\(.*\)</name>,\1,p' $sourcedir/rules/(evdev|base).xml(.N[1])) ) ;; + rules) matches=( $sourcedir/rules/*.lst(-.:t:r) ) ;; + types) matches=( $sourcedir/types/^README(.:t) ) ;; + variants) + [[ -n $layout && -r $sourcedir/symbols/$layout ]] && matches=( + ${${${(M)${(f)"$(<$sourcedir/symbols/$layout)"}:#*xkb_symbols*\"([^\"])##\"*}##*xkb_symbols([^\"])##\"}%%\"*} + ) + ;; + geometries) + if compset -P 1 '*\('; then + layout="${${IPREFIX%$open}##*,}" + suf=( -S"$close$compstate[quote] " ) + matches=( $(sed -n -e '/xkb_geometry/ s/[^"]*"\([^"]*\).*/\1/p' $sourcedir/geometry/${IPREFIX%%[\\(]#}(.N)) ) + else + suf=( -S$open -r "('\" \t\n\-" ) + matches=( $sourcedir/geometry/^README(.:t) ) + fi + ;; + devices) + # copied from _xinput + if (( $+commands[xinput] )); then + local -a ids names disp + local out + ids=( ${${(f)"$(_call_program input-devices xinput list --id-only)"}#? } ) + names=( ${${(f)"$(_call_program input-devices xinput list --name-only)"}#? } ) + disp=( ${(f)"$(_call_program input-devices xinput list --short)"} ) + + if [[ $PREFIX$SUFFIX = [^-]*[^0-9]* ]]; then + # match based on the names but insert IDs + compadd "$expl[@]" -M 'b:=* m:{[:lower:]}={[:upper:]}' -D ids -D disp -a names + compadd "$expl[@]" -U -ld disp -a ids && ret=0 + + zstyle -s ":completion:${curcontext}:input-devices" insert-ids out || out=menu + case "$out" in + menu) compstate[insert]=menu ;; + single) [[ $#ids -ne 1 && $compstate[insert] != menu ]] && + compstate[insert]= ;; + *) [[ ${#:-$PREFIX$SUFFIX} -gt ${#compstate[unambiguous]} ]] && + compstate[insert]=menu ;; + esac + else + compadd "$expl[@]" -M 'B:0=' -o nosort -ld disp -a ids && ret=0 + fi + fi + return ret + ;; esac -} - -_setxkbmap_files () { - local dir="$1" - local label="$2" - - local -a fullpath shortpath expl - - fullpath=($sourcedir/$dir/**/*~*README(.)) - shortpath=(${fullpath#$sourcedir\/$dir\/}) - - _wanted layout expl $label compadd -a - shortpath - -} - -(( $+functions[_setxkbmap_compat] )) || -_setxkbmap_compat() { - _setxkbmap_files "compat" "compatibility" -} - -(( $+functions[_setxkbmap_layout] )) || -_setxkbmap_layout () { - _setxkbmap_files "symbols" "layout" -} - -(( $+functions[_setxkbmap_geometry] )) || -_setxkbmap_geometry () { - _setxkbmap_files "geometry" "geometry" -} - -(( $+functions[_setxkbmap_variant] )) || -_setxkbmap_variant () { - local file=$sourcedir/symbols/${1} - local -a variants lines expl - - if [ ! -f $file ]; then - _message "no such layout: ${1}" - return 1 - fi - - lines=("${(f)$(< ${file})}") - variants=(${${${(M)lines:#*xkb_symbols*\"([^\"])##\"*}##*xkb_symbols([^\"])##\"}%%\"*}) - - _wanted variant expl 'variant' compadd -a variants - -} + fi + compadd "$expl[@]" $suf -a matches && ret=0 +fi -_setxkbmap "$@" +return ret diff --git a/Completion/Zsh/Context/_equal b/Completion/Zsh/Context/_equal index 58a415d56..5cdeea264 100644 --- a/Completion/Zsh/Context/_equal +++ b/Completion/Zsh/Context/_equal @@ -1,3 +1,11 @@ #compdef -equal- -_path_commands +local -a match mbegin mend + +if _have_glob_qual $PREFIX; then + compset -p ${#match[1]} + compset -S '[^\)\|\~]#(|\))' + _globquals +else + _path_commands +fi diff --git a/Completion/Zsh/Type/_module_math_func b/Completion/Zsh/Type/_module_math_func index 5044bdf4c..e92b78b71 100644 --- a/Completion/Zsh/Type/_module_math_func +++ b/Completion/Zsh/Type/_module_math_func @@ -2,7 +2,7 @@ local mod local -a funcs alts -local -a modules=( example mathfunc system ) +local -a modules=( example mathfunc system random ) for mod in $modules; do funcs=( ${${${(f)"$(zmodload -Fl zsh/$mod 2>/dev/null)"}:#^+f:*}##+f:} ) |