diff options
Diffstat (limited to 'Completion/X/Command')
| -rw-r--r-- | Completion/X/Command/_acroread | 119 | ||||
| -rw-r--r-- | Completion/X/Command/_chromium | 192 | ||||
| -rw-r--r-- | Completion/X/Command/_dcop | 119 | ||||
| -rw-r--r-- | Completion/X/Command/_firefox | 328 | ||||
| -rw-r--r-- | Completion/X/Command/_mozilla | 150 | ||||
| -rw-r--r-- | Completion/X/Command/_mplayer | 2 | ||||
| -rw-r--r-- | Completion/X/Command/_nedit | 2 | ||||
| -rw-r--r-- | Completion/X/Command/_netscape | 93 | ||||
| -rw-r--r-- | Completion/X/Command/_papers | 18 | ||||
| -rw-r--r-- | Completion/X/Command/_pdftk | 17 | ||||
| -rw-r--r-- | Completion/X/Command/_xv | 2 |
11 files changed, 547 insertions, 495 deletions
diff --git a/Completion/X/Command/_acroread b/Completion/X/Command/_acroread deleted file mode 100644 index 4a5cb5cb8..000000000 --- a/Completion/X/Command/_acroread +++ /dev/null @@ -1,119 +0,0 @@ -#compdef acroread - -local curcontext="$curcontext" state line -local cmdfile - -if [[ -z $_acroread_version ]]; then - _acroread_version="$($words[1] -version 2>/dev/null)" -fi - -if [[ -z $_acroread_version ]]; then - if [[ $words[1] = */* && -x $words[1] ]]; then - cmdfile=$words[1] - elif [[ -x $commands[$words[1]] ]]; then - cmdfile=$commands[$words[1]] - fi - - # Try extracting the version number directly from the executable. - # (This will fail if the executable is a wrapper script for acroread.) - _acroread_version=${${(M)${(f)"$(<$cmdfile)"}:#ver=*}##ver=} - - if [[ -z $_acroread_version ]]; then - local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]} - if [[ -r $acropath ]]; then - _acroread_version=${${(M)${(f)"$(<$acropath)"}:#ver=*}##ver=} - fi - fi -fi - -if [[ $_acroread_version == [789].* ]]; then - local -a extra_args - extra_args=() - if [[ $_acroread_version == [89].* ]]; then - extra_args+=(-man '-installCertificate:server ip::server port') - fi - if [[ $_acroread_version == 9.* ]]; then - extra_args+=(-openInNewInstance) - fi - _arguments -C \ - "${extra_args[@]}" \ - '--display=:X display:_x_display' \ - '--screen=:X screen (overrides the screen part of DISPLAY)' \ - --sync \ - '-geometry:[<width>x<height>][{+|-}<x offset>{+|-}<y offset>]' \ - -help \ - -iconic \ - '*-setenv:<var>=<value>' \ - -tempFile \ - '-tempFileTitle:title' \ - -openInNewWindow \ - -version \ - '-visual:X visual:_x_visual' \ - '-toPostScript:*::PostScript conversion options:= ->tops' \ - '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return - - [[ -n "$state" ]] && _arguments \ - '-pairs:*:pdf_file_1 ps_file_1 ...:_files -g "*.(#i)(pdf|ps)(-.)"' \ - -binary \ - '-start:integer' \ - '-end:integer' \ - -optimizeForSpeed \ - -landscape \ - -reverse \ - '(-even)-odd' \ - '(-odd)-even' \ - -commentsOff \ - -annotsOff \ - -stampsOff \ - -markupsOn \ - '(-level3)-level2' \ - '(-level2)-level3' \ - -printerhalftones \ - -saveVM \ - '-scale:integer' \ - -shrink \ - -expand \ - '-size:page size (or custom size wxh in points):(letter tabloid ledger legal executive a3 a4 a5 b4 b5)' \ - '-transQuality:transparency flattening level:(1 2 3 4 5)' \ - '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return -else - _x_arguments -C \ - -help \ - -helpall \ - \*-iconic \ - \*+iconic \ - '-name:application name:_x_name' \ - '*-setenv:<var>=<value>' \ - -tempFile \ - '-tempFileTitle:title' \ - '(+useFrontEndProgram)-useFrontEndProgram' \ - '(-useFrontEndProgram)+useFrontEndProgram' \ - '-visual:X visual:_x_visual' \ - '-xrm:X resource specification:_x_resource' \ - '-toPostScript:*::PostScript conversion options:= ->tops' \ - '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return - - [[ -n "$state" ]] && _arguments \ - '-pairs:*:pdf_file_1 ps_file_1 ...:_files -g "*.(#i)(pdf|ps)(-.)"' \ - -binary \ - '-start:integer' \ - '-end:integer' \ - -optimizeForSpeed \ - -landscape \ - -reverse \ - '(-even)-odd' \ - '(-odd)-even' \ - -commentsOff \ - '(-level2 -level3)-level1' \ - '(-level1 -level3)-level2' \ - '(-level1 -level2)-level3' \ - -printerhalftones \ - -saveVM \ - '-scale:integer' \ - -shrink \ - '-size:page size (or custom size wxh in points):(letter tabloid ledger legal executive a3 a4 a5 b4 b5)' \ - '-transQuality:transparency flattening level:(1 2 3 4 5)' \ - '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return -fi - -return 1 diff --git a/Completion/X/Command/_chromium b/Completion/X/Command/_chromium new file mode 100644 index 000000000..be5e9bab3 --- /dev/null +++ b/Completion/X/Command/_chromium @@ -0,0 +1,192 @@ +#compdef chrome chromium google-chrome brave cromite helium helium-browser microsoft-edge opera opera-gx ungoogled-chromium vivaldi -P google-chrome-* brave-* microsoft-edge-* opera-* vivaldi-* + +(( $+functions[_chromium_urls] )) || +_chromium_urls() { + # chromium doesn't allow you to open about: or chrome:// urls from the cli, + # except for about:blank + _alternative \ + 'files: :_files' \ + 'urls: :_urls' \ + 'urls-about:about page:(about\:blank)' +} + +# complete possible data directories (and, without -0, generic paths). as with +# firefox, we could try harder to look for the *exact* directory we need, but +# this is probably fine +# -0 <name> instead of completing, insert directories into array <name> +# -a use all possible directories instead of service-specific ones +(( $+functions[_chromium_data_dirs] )) || +_chromium_data_dirs() { + local cfg=${XDG_CONFIG_HOME:-$HOME/.config} + local -a ca_opts expl dirs + local -A opth + + zparseopts -A opth -D -F - \ + {M+:,P+:,q+:,r+:,R+:,S+:}=ca_opts 1 2 J: o: O: V: x: X: \ + 0: a \ + || return + + local -a chrome_dirs=( + $cfg/google-chrome{,-beta,-unstable,-canary} + $HOME/.var/app/com.google.Chrome/config/google-chrome + "$HOME/Library/Application Support/Google/Chrome"{,\ Beta,\ Dev,\ Canary} + ) + local -a chromium_dirs=( + $cfg/chromium + $HOME/snap/chromium/current/.config/chromium + $HOME/.var/app/org.chromium.Chromium/config/chromium + "$HOME/Library/Application Support/Chromium" + ) + local -a brave_dirs=( + $cfg/brave{,-beta,-development,-unstable} + $cfg/BraveSoftware/Brave-Browser{,-Beta,-Dev,-Development,-Nightly} + $HOME/.var/app/com.brave.Browser/config/BraveSoftware/Brave-Browser + "$HOME/Library/Application Support/BraveSoftware/Brave-Browser"{,-Beta,-Dev,-Development,-Nightly} + ) + local -a cromite_dirs=( + $cfg/cromite + ) + local -a helium_dirs=( + $cfg/net.imput.helium + "$HOME/Library/Application Support/net.imput.helium" + ) + local -a edge_dirs=( + $cfg/microsoft-edge{,-beta,-dev,-canary} + "$HOME/Library/Application Support/Microsoft Edge"{,\ Beta,\ Dev,\ Canary} + ) + local -a opera_gx_dirs=( + $cfg/opera-gx + $HOME/.var/app/com.opera.opera-gx/config/opera + "$HOME/Library/Application Support/com.operasoftware.OperaGX" + ) + local -a opera_dirs=( + $cfg/opera{,-beta,-developer} + $HOME/.var/app/com.opera.Opera/config/opera + "$HOME/Library/Application Support/com.operasoftware.Opera" + ) + local -a vivaldi_dirs=( + $cfg/vivaldi{,-snapshot} + $HOME/.var/app/com.vivaldi.Vivaldi/config/vivaldi + "$HOME/Library/Application Support/Vivaldi"{,\ Snapshot} + ) + + if (( $+opth[-a] )); then + dirs=( + $chrome_dirs $chromium_dirs $brave_dirs $cromite_dirs + $helium_dirs $edge_dirs $opera_gx_dirs $opera_dirs $vivaldi_dirs + ) + + else + case $service in + google*|chrome*) dirs=( $chrome_dirs ) ;; + chromium*|ungoogled*) dirs=( $chromium_dirs ) ;; + brave*) dirs=( $brave_dirs ) ;; + cromite*) dirs=( $cromite_dirs ) ;; + helium*) dirs=( $helium_dirs ) ;; + microsoft*|edge*) dirs=( $edge_dirs ) ;; + opera-gx*) dirs=( $opera_gx_dirs ) ;; + opera*) dirs=( $opera_dirs ) ;; + vivaldi*) dirs=( $vivaldi_dirs ) ;; + esac + fi + + dirs=( $^dirs/'Local State'(#qN.-) ) + dirs=( ${dirs:h} ) + dirs=( ${(u)dirs} ) + + (( $+opth[-0] )) && { + trap "${opth[-0]}=( ${(j< >)${(@q+)dirs}} )" EXIT + return $(( ! $#dirs )) + } + + dirs=( ${dirs//:/\:} ) + + _describe -t data-directories 'user data directory' \ + dirs "${(@)ca_opts}" && ret=0 + _wanted files expl 'user data directory' \ + _files -/ "${(@)ca_opts}" && ret=0 + + return ret +} + +(( $+functions[_chromium_profile_dirs] )) || +_chromium_profile_dirs() { + local -a ca_opts cli_dirs dirs profiles disp inst + local -A opth + + zparseopts -A opth -D -F - \ + {1,2,J+:,M+:,o+:,O+:,P+:,q+,r+:,R+:,S+:,V+:,x+:,X+:}=ca_opts \ + a \ + || return + + cli_dirs=( ${${(MQ)words:#--user-data-dir=*}#*=} ) + + if (( $+opth[-a] )); then + _chromium_data_dirs -a0dirs + dirs+=( $cli_dirs ) + else + dirs=( $cli_dirs ) + (( $#dirs )) || _chromium_data_dirs -0dirs + fi + + # the name given to a profile by the user has no relationship at all to the + # profile's directory name. to make the results meaningful, we'll try to parse + # the dirs + names out of the config + (( $+commands[python3] )) && + profiles=( ${(f)"$( + python3 -c 'if 1: + import json, re, sys + for st in sys.argv[1:]: + with open(st) as f: + ps = json.load(f).get("profile", {}).get("info_cache", {}) + for k, v in ps.items(): + dir = k + nam = v.get("name", "") + print(f"{nam}\0{dir}") + ' $^dirs/'Local State'(#qN.-) + )"} ) + + (( $#profiles )) || profiles=( $^dirs/(Default|Profile\ *)(#qN/-:t) ) + + disp=( ${${profiles//:/\\:}/$'\0'/:} ) + inst=( ${profiles#*$'\0'} ) + + _describe -t profiles 'profile directory' disp inst "${(@)ca_opts}" +} + +# chromium has hundreds of options, largely undocumented and apparently +# unstable. we make no attempt to support them all. these are the ones i found +# to be most commonly referenced +local -a args=( + + '(excl)' + '(- : *)--version[display version information]' + + + '(open)' + '--incognito[open new Incognito window or tab]' + '--new-tab[open new tab]' + '--new-window[open new window]' + + + '(proxy)' + '--proxy-server=-[specify proxy server]:proxy server:{ + compset -P "(http|socks|socks4|socks5)\://" + _hosts "${(@)expl}" + }' + '--no-proxy-server[disable proxy server]' + '--proxy-auto-detect[auto-detect proxy configuration]' + # @todo this has to be http://, https://, or data: + '--proxy-pac-url=-[specify proxy auto-configuration URL]:PAC-file URL:_urls' + + + misc + '(*)--app=-[open specified URL in app mode]: :_chromium_urls' + '--password-store=-[specify password storage back-end]:password store:( + basic gnome gnome-libsecret kwallet kwallet5 kwallet6 + )' + '--user-data-dir=-[specify user data directory]: :_chromium_data_dirs -a' + '--profile-directory=-[specify profile directory]: :_chromium_profile_dirs' + '(--app)*: :_chromium_urls' +) + +[[ $service == (microsoft|edge)* ]] && +args=( ${${args//incognito/inprivate}//Incognito/InPrivate} ) + +_arguments -s -S : $args diff --git a/Completion/X/Command/_dcop b/Completion/X/Command/_dcop deleted file mode 100644 index a0329e110..000000000 --- a/Completion/X/Command/_dcop +++ /dev/null @@ -1,119 +0,0 @@ -#compdef dcop dcopstart dcopfind dcopref dcopclient dcopobject - -local curcontext="$curcontext" desc vals arg base max=0 ret=1 -local app obj fun -local -a state line expl - -case $service in - dcop(client|object)) - state=( dcopref ) - max=2 - ;; - dcopref) max=3 ;; - dcopstart) - if (( CURRENT > 2 )); then - _urls && return - fi - ;; - dcopfind) - local cmd=$words[1] - _arguments -C \ - '-a[print application id instead of DCOPRef]' \ - '-l[if object not found, run dcopstart and retry]' \ - '*::args:->args' && ret=0 - unset state - words=( $cmd $words ) - (( CURRENT++ )) - ;; -esac - -if (( max && CURRENT > max )); then - _message 'no more arguments' - return 1 -fi - -if [[ -z "$state" ]]; then - state=(application object function) - [[ $words[2] = DCOPRef* && CURRENT -ne 2 ]] - base=$? - state=( ${state[CURRENT-base]:-arg} ) - - [[ $state[1] = application && $service = dcop(|find) ]] && state+=( dcopref ) -fi - -while (( $#state )); do - unset app obj fun - - if [[ $words[2] = (#b)DCOPRef*\(([^,]#)((#e)|,)([^\\\)]#)(*) ]]; then - if [[ -n $match[2] ]]; then - app=$match[1] - if [[ -n $match[4] ]]; then - obj=$match[3] - [[ -n $words[3] && CURRENT -gt 3 ]] && fun=$words[3] - fi - fi - else - case $CURRENT in - <5->) fun="$words[4]" ;& - 4) obj="$words[3]" ;& - 3) app="$words[2]" ;; - esac - fi - vals=( ${(f)"$(_call_program dcop-$state[1]s ${(M)words[1]##*/}dcop $app $obj 2>/dev/null)"} ) - - case "$state[1]" in - application|object) - [[ -n ${(M)vals:#*\(default\)} ]] && vals+=( default ) - _wanted dcop-$state[1]s expl $state[1] compadd "$@" - ${vals% \(default\)} && ret=0 - ;; - - function) - [[ $service = dcopfind ]] && vals=( ${(M)vals:#bool *} ) - _wanted dcop-$state[1]s expl $state[1] compadd "$@" - ${${vals#* }%\(*} && ret=0 - ;; - - arg) - arg=${${${(M)vals:#*$fun\(*}#*\(}%\)*}, - arg=${${(s.,.)arg}[CURRENT-base-3]} - if [[ -n $arg ]]; then - if [[ $arg = (Q(|C)String|*int )* || $arg != *\ * ]]; then - # don't mention the argument's type - desc="${arg##* }" - else - desc="${arg##* } (${arg% *})" - fi - case $arg in - bool*) _wanted argument expl "$desc" compadd true false && return ;; - (#i)*(file|path|dir)*) _wanted argument expl "$desc" _files && return ;; - (#i)*url*) _wanted argument expl "$desc" _urls && return ;; - *) _message -e argument "$desc" ;; - esac - else - _message 'no more arguments' - fi - ;; - - dcopref) - if ! compset -P '*\('; then - _wanted dcoprefs expl 'dcop ref' compadd -S '' 'DCOPRef(' && ret=0 - elif compset -P '*,'; then - if compset -S '(|\\)\)*'; then - set -- -S '' "$@" - else - set -- "$@" -S"${${QIPREFIX:+)}:-\)}$compstate[quote] " - fi - state+=( object ) - else - if compset -S ',*'; then - set -- "$@" -S '' - else - set -- "$@" -S , - fi - state+=( application ) - fi - ;; - esac - shift state -done - -return ret diff --git a/Completion/X/Command/_firefox b/Completion/X/Command/_firefox new file mode 100644 index 000000000..c8a9f0ec0 --- /dev/null +++ b/Completion/X/Command/_firefox @@ -0,0 +1,328 @@ +#compdef firefox mozilla-firefox=firefox floorp librewolf mullvad-browser mullvadbrowser palemoon tor-browser torbrowser waterfox zen zen-browser -P firefox* + +(( $+functions[_firefox_urls] )) || +_firefox_urls() { + if compset -P about:; then + _describe -t urls-about 'about page' '( + about addons buildconfig cache certificate checkerboard compat + config crashes credits debugging downloads firefoxview home + keyboard license logging logins loginsimportreport logo memory + mozilla networking newtab policies preferences privatebrowsing + processes profiles profiling protections rights robots + serviceworkers studies support sync-log telemetry translations + unloads url-classifier webauthn webrtc welcome + )' + elif compset -P mailto:; then + _email_addresses -c + else + _alternative 'files: :_files' 'urls: :_urls' + fi +} + +# complete possible config directories. we could try harder to look for the +# *exact* directory we need, but this should work in most cases +# -0 <name> instead of completing, insert directories into array <name> +# -a use all possible directories instead of service-specific ones +(( $+functions[_firefox_config_dirs] )) || +_firefox_config_dirs() { + local cfg=${XDG_CONFIG_HOME:-$HOME/.config} + local -a ca_opts dirs + local -A opth + + zparseopts -A opth -D -F - \ + {1,2,J+:,M+:,o+:,O+:,P+:,q+,r+:,R+:,S+:,V+:,x+:,X+:}=ca_opts \ + 0: a \ + || return + + local -a firefox_dirs=( + $cfg/mozilla/firefox + $HOME/.mozilla/firefox + $HOME/.var/app/org.mozilla.firefox/.mozilla/firefox + $HOME/snap/firefox/common/.mozilla/firefox + "$HOME/Library/Application Support/Firefox" + ) + local -a floorp_dirs=( + $cfg/floorp/floorp # unverified + $HOME/.floorp + $HOME/.var/app/one.ablaze.floorp/.floorp + "$HOME/Library/Application Support/Floorp" + ) + local -a librewolf_dirs=( + $cfg/librewolf/librewolf + $HOME/.librewolf + $HOME/.var/app/io.gitlab.librewolf-community/.librewolf + "$HOME/Library/Application Support/librewolf" + ) + local -a mullvad_dirs=( + # based on tor browser, probably works similar + $HOME/.var/app/net.mullvad.MullvadBrowser/.mullvad-browser/.mullvad/mullvadbrowser + "$HOME/Library/Application Support/MullvadBrowser" + ) + local -a palemoon_dirs=( + "$HOME/.moonchild productions/pale moon" + "$HOME/Library/Application Support/Pale Moon" + ) + local -a tor_dirs=( + # i think on linux the ~/.mozilla equivalent normally lives inside the same + # directory the browser is installed to? but i couldn't verify + "$HOME/Library/Application Support/TorBrowser-Data/Browser" + ) + local -a waterfox_dirs=( + $cfg/waterfox/waterfox # unverified + $HOME/.waterfox + $HOME/.var/app/net.waterfox.waterfox/.waterfox + "$HOME/Library/Application Support/Waterfox" + ) + local -a zen_dirs=( + $cfg/zen/zen + $HOME/.zen + $HOME/.var/app/app.zen_browser.zen/.zen + $HOME/.var/app/io.github.zen_browser.zen/.zen + "$HOME/Library/Application Support/zen" + ) + + if (( $+opth[-a] )); then + dirs=( + $firefox_dirs $floorp_dirs $librewolf_dirs $mullvad_dirs + $palemoon_dirs $tor_dirs $waterfox_dirs $zen_dirs + ) + else + case $service in + firefox*) dirs=( $firefox_dirs ) ;; + floorp*) dirs=( $floorp_dirs ) ;; + librewolf*) dirs=( $librewolf_dirs ) ;; + mullvad*) dirs=( $mullvad_dirs ) ;; + palemoon*) dirs=( $palemoon_dirs ) ;; + tor*) dirs=( $tor_dirs ) ;; + waterfox*) dirs=( $waterfox_dirs ) ;; + zen*) dirs=( $zen_dirs ) ;; + esac + fi + + dirs=( $^dirs/profiles.ini(#qN-.) ) + dirs=( ${dirs:h} ) + dirs=( ${(u)dirs} ) + + (( $+opth[-0] )) && { + trap "${opth[-0]}=( ${(j< >)${(@q+)dirs}} )" EXIT + return $(( ! $#dirs )) + } + + dirs=( ${dirs//:/\:} ) + + _describe -t profile-directories 'profile directory' dirs "${(@)ca_opts}" +} + +# complete old-style ToolkitProfileService profiles +# -0 <name> instead of completing, insert NUL-separated name/path pairs into +# array <name> +# -a see _firefox_profile_dirs +(( $+functions[_firefox_toolkit_profiles] )) || +_firefox_toolkit_profiles() { + local dir + local -a ca_opts tmp dirs profiles + local -A opth + + zparseopts -A opth -D -F - \ + {1,2,J+:,M+:,o+:,O+:,P+:,q+,r+:,R+:,S+:,V+:,x+:,X+:}=ca_opts \ + 0: a \ + || return + + _firefox_config_dirs ${opth[-a]+-a} -0dirs + + # if we don't care about the paths we can use a simpler method + if (( ! $+opth[-0] )); then + for dir in $dirs; do + tmp=( ${(f)"$( < $dir/profiles.ini )"} ) + tmp=( ${(M)tmp:#[[:space:]]#Name=*} ) + tmp=( ${tmp#*=} ) + profiles+=( $tmp ) + done + + elif (( $+commands[python3] )); then + profiles=( ${(f)"$( + python3 -c 'if 1: + import configparser, re, sys + for dir in sys.argv[1:]: + cfg = configparser.ConfigParser() + cfg.read(f"{dir}/profiles.ini") + for sct in cfg.sections(): + if not sct.startswith("Profile") or not cfg[sct].get("Name"): + continue + name = cfg[sct].get("Name") + path = cfg[sct].get("Path") + # ignore Windows path + if "/" not in path and "\\" in path: + continue + if cfg[sct].get("IsRelative") == "1": + path = f"{dir}/{path}" + print(f"{name}\0{path}") + ' $dirs + )"} ) + fi + + (( $+opth[-0] )) && { + trap "${opth[-0]}=( ${(j< >)${(@q+)profiles}} )" EXIT + return $(( ! $#profiles )) + } + + profiles=( ${profiles%%$'\0'*} ) + profiles=( ${profiles//:/\:} ) + + _describe -t toolkit-profiles 'toolkit profile' profiles "${(@)ca_opts}" +} + +# complete new-style SelectableProfileService profiles +# -0 <name> see _firefox_toolkit_profiles +# -a see _firefox_toolkit_profiles +(( $+functions[_firefox_selectable_profiles] )) || +_firefox_selectable_profiles() { + local dir db + local -a ca_opts tmp dirs profiles + local -A opth + + zparseopts -A opth -D -F - \ + {1,2,J+:,M+:,o+:,O+:,P+:,q+,r+:,R+:,S+:,V+:,x+:,X+:}=ca_opts \ + 0: a \ + || return + + _firefox_config_dirs ${opth[-a]+-a} -0dirs + + (( $+commands[sqlite3] )) && + for dir in $dirs; do + # apparently firefox sometimes re-creates these databases, so there can be + # more than one in the directory. the active one is stored in preferences, + # but we'll just assume it's the newest + for db in "$dir/Profile Groups/"*.sqlite(#qN-.om[1]); do + tmp+=( ${${(f)"$( + sqlite3 -separator $'\x1f' $db 'SELECT name, path FROM Profiles;' + )"}//$'\x1f'/$'\0'} ) + for 1 2 in "${(@0)tmp}"; do + [[ $2 != */* && $2 == *\\* ]] && continue # ignore Windows path + [[ $2 == /* ]] || 2=${db:h:h}/$2 # make absolute + profiles+=( $1$'\0'$2 ) + done + done + done + + (( $+opth[-0] )) && { + trap "${opth[-0]}=( ${(j< >)${(@q+)profiles}} )" EXIT + return $(( ! $#profiles )) + } + + profiles=( ${profiles%%$'\0'*} ) + profiles=( ${profiles//:/\:} ) + + _describe -t selectable-profiles 'selectable profile' profiles "${(@)ca_opts}" +} + +# at time of writing, there's no specific way to use/manage the newer +# SelectableProfileService profiles from the cli. however, it's possible to load +# one by giving its path to --profile, which is a common work-around. to make +# this more convenient, we offer these profile paths in addition to the generic +# path completion +# -a see _firefox_toolkit_profiles +(( $+functions[_firefox_profile_dirs] )) || +_firefox_profile_dirs() { + local ret=1 + local -a ca_opts expl profiles disp inst + + zparseopts -A opth -D -F - \ + {M+:,P+:,q+:,r+:,R+:,S+:}=ca_opts 1 2 J: o: O: V: x: X: \ + a \ + || return + + _firefox_toolkit_profiles ${opth[-a]+-a} -0profiles && { + disp=( ${${profiles//:/\\:}/$'\0'/:} ) + inst=( ${profiles#*$'\0'} ) + _describe -t toolkit-profiles 'toolkit profile directory' \ + disp inst "${(@)ca_opts}" && ret=0 + } + + _firefox_selectable_profiles ${opth[-a]+-a} -0profiles && { + disp=( ${${profiles//:/\\:}/$'\0'/:} ) + inst=( ${profiles#*$'\0'} ) + _describe -t selectable-profiles 'selectable profile directory' \ + disp inst "${(@)ca_opts}" && ret=0 + } + + _wanted files expl 'profile directory' _files -/ "${(@)ca_opts}" && ret=0 + + return ret +} + +local x +local -a match mbegin mend tmp args + +tmp=( + + '(excl)' + '(- : *)'{-h,--help}'[display help information]' + '(- : *)'{-v,--version}'[display version information]' + '(- : *)--full-version[display version and build information]' + + + '(start)' + # not in help output for some reason + '--CreateProfile=[create new profile with specified name]:profile name' + '-P=[start with profile manager or specified profile]:: :_firefox_toolkit_profiles' + '--profile=[start with profile at specified path]: :_firefox_profile_dirs -a' + '--migration[start with migration wizard]' + '--ProfileManager[start with profile manager]' + + + misc + '--g-fatal-warnings[make all warnings fatal]' + '--origin-to-force-quic-on=[force to use QUIC for specified origin]: :_urls' + '--new-instance[open new instance instead of new window]' + '--safe-mode[disable extensions and themes]' + '--allow-downgrade[allow downgrading profile]' + '--MOZ_LOG=[specify log modules]:log modules' + '--MOZ_LOG_FILE=[specify log file]:log file:_files' + '--headless[run without GUI]' + '--browser[open browser window]' + '*--new-window=[open new window (specify URL)]:: :_firefox_urls' + '*--new-tab=[open new tab (specify URL)]:: :_firefox_urls' + '*--private-window=[open new private window (specify URL)]:: :_firefox_urls' + '--preferences[open about\:preferences]' + '--screenshot=[save screenshot (specify path)]::screenshot path:_files' + '--window-size=[specify width and height of screenshot (with --screenshot)]:screenshot window size (width[,height])' + '--search=[search for specified term with default search engine]:search term' + '--setDefaultBrowser[set as default browser]' + '--first-startup[run post-install actions before opening new window]' + '--kiosk[start in kiosk mode]' + '--kiosk-monitor=[place kiosk browser window on specified monitor]: :_numbers "monitor number"' + '--disable-pinch[disable touch-screen and touch-pad pinch gestures]' + '--jsconsole[open Browser Console]' + '--devtools[open DevTools on initial load]' + '--jsdebugger=[open Browser Toolbox (specify Firefox path)]::Firefox path:_files' + '--wait-for-jsdebugger[spin event loop until JS debugger connects (with --jsdebugger)]' + '--start-debugger-server=[start devtools server at specified port or socket path]: :{ + compset -P ws\: + _alternative \ + "ports\: \:_numbers -l1 -m65535 \"port number\"" \ + "files\:socket path\:_files -g \"(#q-=)\"" + }' + '--marionette[enable remote control server]' + '--remote-debugging-port=[start Firefox Remote Agent (specify port)]:: :\ + _numbers -l1 -m65535 -d9222 "port number" + ' + '--remote-allow-hosts=[specify Host header values to allow for incoming requests (with --remote-debugging-port)]:Host header value:\ + _sequence -s, _hosts + ' + '--remote-allow-origins=[specify Origin header values to allow for incoming requests (with --remote-debugging-port)]:Origin header value:\ + _sequence -s, _urls + ' + "--remote-allow-system-access[enable privileged access to application's parent process (with --remote-debugging-port)]" + + '*: :_firefox_urls' +) + +# options support both single and double hyphens. recognise the alternate forms +for x in $tmp; do + args+=( $x ) + [[ $x == (#b)(|\(*\))(|\*)(--|-)([^-]*) ]] && { + [[ $match[3] == - ]] && match[3]=-- || match[3]=- + args+=( \!${(j<>)match} ) + } +done + +# options are also case-insensitive +_arguments -s -S -M 'm:{A-Za-z}={a-zA-Z} r:|[_-]=* r:|=*' : $args diff --git a/Completion/X/Command/_mozilla b/Completion/X/Command/_mozilla deleted file mode 100644 index 0be25b8d3..000000000 --- a/Completion/X/Command/_mozilla +++ /dev/null @@ -1,150 +0,0 @@ -#compdef mozilla mozilla-firefox mozilla-xremote-client firefox iceweasel=firefox - -local curcontext="$curcontext" state line expl ret=1 suf -typeset -A opt_args - -local popts="-installer -CreateProfile -P -ProfileWizard -ProfileManager -SelectProfile" -local -a mozopts - -if [[ $service = *remote* ]]; then - state=remote -else - if [[ $service = *firefox* ]]; then - mozopts=( - '-browser[open browser window]' \ - '-console[start with debugging console]' \ - '-h[output help message]' \ - '-help[output help message]' \ - '-inspector[start with DOM Inspector]:URL to inspect:->location' \ - '-install-global-extension[install an extension]:extension to install:_files' \ - '-new-window[load URL in new window]:URL to load:->location' \ - '-new-tab[load URL in new tab]:URL to load:->location' \ - '-no-remote[run with multiple profiles]' \ - '-profile[specify profile file]:profile file:_files' \ - '-v[show version]' \ - '-version[show version]' \ - '-safe-mode[disable extensions and themes for this session]' - ) - else - mozopts=( - "($popts)-installer[start with 4.x migration window]" - "($popts)-ProfileWizard[start with profile wizard]" - "($popts)-SelectProfile[start with profile selection dialog]" - '-splash[enable splash screen]' - '-chat[start with IRC client]' - '-news[start with news]' - '-venkman[start with JavaScript debugger]' - '-terminal[start with command line terminal]' - '-mail[start with mail]' - '-compose[start with messenger compose]:URL:_urls' - ) - fi - _x_arguments -C $mozopts \ - '-height[height of startup window]:height' \ - '(-)'{-h,-help}'[show usage message]' \ - "($popts)-CreateProfile:profile" \ - '-width[width of startup window]:width' \ - '(-)'{-v,-version}'[show the version number and build date]' \ - "($popts)-P[start with profile]:profile:->profile" \ - "($popts)-ProfileManager[start with profile manager]" \ - '-UILocale:locale' \ - '-contentLocale:locale' \ - '-remote[execute a command in an existing Mozilla]:remote command:->remote' \ - '-jsconsole[start with JavaScript Console]' \ - '-edit[start with editor]:URL:_urls' \ - '-chrome[load the specified chrome]:URL:_urls' \ - '*:location:->urls' && ret=0 -fi - -[[ "$state" = "urls" ]] && - _files "$@" && return 0 - -# Handle mozilla remote commands -if [[ "$state" = "remote" ]]; then - local -a remote_commands - remote_commands=(openURL openFile saveAs mailto addBookmark ping) - - compset -P '*\(' - if compset -S '(|\\)\)*'; then - set - -S "" "$@" - else - set - -S"${${QIPREFIX:+)}:-\)}$compstate[quote] " "$@" - fi - case $IPREFIX in - openURL*) - if compset -P "*,"; then - _wanted option expl 'option' compadd "$@" new-tab new-window && ret=0 - else - compset -S ',*' - state=urls - fi - ;; - addBookmark*) state=urls;; - openFile*) _files "$@" -W ~;; - saveAs*) - if compset -P "*,"; then - _wanted types expl 'data type' \ - compadd "$@" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript && ret=0 - else - compset -S ",*" || suf="," - _files -qS "$suf" -W ~ && ret=0 - fi - ;; - mailto*) - _email_addresses -s, -c && ret=0 - ;; - *) - compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}" - _wanted commands expl 'remote command' \ - compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' -a \ - remote_commands && ret=0 - ;; - esac -fi - -if [[ "$state" = "urls" ]]; then - # Complete mozilla urls - if compset -P about: ; then - _wanted values expl 'about what' \ - compadd "$@" authors blank cache document fonts global hype image-cache \ - license logo memory-cache mozilla plugins && ret=0 - elif compset -P news: ; then - _newsgroups "$@" && ret=0 - elif compset -P mailto: ; then - _email_addresses -c && ret=0 - else - _tags prefixes - while _tags; do - while _next_label prefixes expl 'URL prefix' "$@"; do - _urls "$expl[@]" && ret=0 - compset -S '[^:]*' - compadd -S '' "$expl[@]" about: news: mailto: mocha: javascript: && ret=0 - done - (( ret )) || return 0 - done - fi -fi - -if [[ $state == "profile" ]]; then - if [[ $service == *firefox* ]]; then - local -a profiles text profiledir - case "$OSTYPE" in - darwin*) profiledir=~/"Library/Application Support/Firefox" ;; - *) profiledir=~/.mozilla/firefox/ ;; - esac - profiles=(${(f)"$(< ${profiledir}/profiles.ini)"}) - profiles=(${(M)${profiles}:#(\[Profile|(Path|Name)=)*}) - text=${(F)profiles} - profiles=(${(f)text//(#b)\[Profile([0-9]##)\] -Name=([^ -]##|) -Path=([^ -]##|)/$match[2]}) - profiles=(${profiles%:}) - compadd $profiles - else - compadd ~/.mozilla/*/*.slt(\:h\:t) - fi -fi - -return ret diff --git a/Completion/X/Command/_mplayer b/Completion/X/Command/_mplayer index 1f99a1789..e954744de 100644 --- a/Completion/X/Command/_mplayer +++ b/Completion/X/Command/_mplayer @@ -115,7 +115,7 @@ case "$state" in _tags files urls while _tags; do _requested files expl 'media file' _files -g \ - "*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4a|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && ret=0 + "*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4a|m4b|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && ret=0 if _requested urls; then while _next_label urls expl URL; do _urls "$expl[@]" && ret=0 diff --git a/Completion/X/Command/_nedit b/Completion/X/Command/_nedit index 75ca1bad4..8bf7cac43 100644 --- a/Completion/X/Command/_nedit +++ b/Completion/X/Command/_nedit @@ -1,4 +1,4 @@ -#compdef nedit nedit-nc=nc ncl=nc +#compdef nedit nedit-nc=nc ncl=nc nedit-client=nc local state line expl nedit_common curcontext="$curcontext" ret=1 typeset -A opt_args diff --git a/Completion/X/Command/_netscape b/Completion/X/Command/_netscape deleted file mode 100644 index 78b2da649..000000000 --- a/Completion/X/Command/_netscape +++ /dev/null @@ -1,93 +0,0 @@ -#compdef netscape - -local curcontext="$curcontext" state line expl ret=1 suf files -typeset -A opt_args - -_x_arguments -C \ - '-xrm:resource:_x_resource' \ - '-help[show usage message]' \ - '-version[show the version number and build date]' \ - '-visual[use a specific server visual]:visual:_x_visual -b' \ - '-install[install a private colormap]' \ - '-no-install[use the default colormap]' \ - '-ncols[max no. of colors to allocate for images]:n:' \ - '-mono[force 1-bit-deep image display]' \ - '-iconic[start up iconified]' \ - '-remote[execute a command in an existing Netscape]:remote command:->remote' \ - '-id[id of X window to send remote commands to]:window-id:' \ - '-raise[raise window following remote command]' \ - "-noraise[don't raise window following remote command]" \ - '-nethelp[show nethelp]' \ - -{dont-force-window-stacking,no-about-splash} \ - -{,no-}{,irix-}session-management \ - -{done-save,ignore}-geometry-prefs \ - -{component-bar,composer,edit,messenger,mail,discussions,news} \ - '*:location:->urls' && ret=0 - -# Handle netscape remote commands -if [[ "$state" = "remote" ]]; then - local -a remote_commands - remote_commands=(openURL openFile saveAs mailto addBookmark) - - compset -P '*\(' - if compset -S '(|\\)\)*'; then - set - -S "" "$@" - else - set - -S"${${QIPREFIX:+)}:-\)}$compstate[quote] " "$@" - fi - case $IPREFIX in - openURL*|addBookmark*) state=urls;; - openFile*) _files "$@" -W ~;; - saveAs*) - if compset -P "*,"; then - _wanted types expl 'data type' \ - compadd "$@" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript && ret=0 - else - compset -S ",*" || suf="," - _files -qS "$suf" -W ~ && ret=0 - fi - ;; - mailto*) - _email_addresses -s, -c && ret=0 - ;; - *) - compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}" - _wanted commands expl 'remote command' \ - compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' -a \ - remote_commands && ret=0 - ;; - esac -fi - -if [[ "$state" = "urls" ]]; then - _tags files urls - while _tags; do - _requested files expl 'file' _files "$@" && files=yes ret=0 - if _requested urls; then - # Complete netscape urls - if compset -P about: ; then - _wanted values expl 'about what' \ - compadd "$@" authors blank cache document fonts global hype \ - image-cache license logo memory-cache mozilla plugins && ret=0 - elif compset -P news: ; then - _newsgroups "$@" && ret=0 - elif compset -P mailto: ; then - _email_addresses -c && ret=0 - else - _tags prefixes - while _tags; do - while _next_label prefixes expl 'URL prefix' "$@"; do - _urls "$expl[@]" && ret=0 - compset -S '[^:]*' - compadd -S '' "$expl[@]" about: news: mailto: mocha: javascript: && ret=0 - done - (( ret )) || return 0 - done - [[ -z "$files" ]] && _tags files - fi - fi - (( ret )) || return 0 - done -fi - -return ret diff --git a/Completion/X/Command/_papers b/Completion/X/Command/_papers new file mode 100644 index 000000000..1c6076728 --- /dev/null +++ b/Completion/X/Command/_papers @@ -0,0 +1,18 @@ +#compdef papers + +_arguments -s -S : \ + + '(help)' \ + '(- : *)--version[display version information]' \ + '(- : *)'{-h,--help}'[display help information]' \ + '(- : *)--help-all[display all help information]' \ + '(- : *)--help-gapplication[display help information for GApplication options]' \ + + '(mode)' \ + {-f,--fullscreen}'[run in fullscreen mode]' \ + {-s,--presentation}'[run in presentation mode]' \ + + '(page)' \ + {-p,--page-label=}'[specify page label of document to display]:page label:' \ + {-i,--page-index=}'[specify page number of document to display]:page index:' \ + {-n,--named-dest=}'[specify named destination to display]:named destination:' \ + + etc \ + '--gapplication-service[enter GApplication service mode]' \ + '*:document file:_files -g "*.(#i)(cb7|cbr|cbt|cbz|djv|djvu|pdf|tif|tiff)(-.)"' diff --git a/Completion/X/Command/_pdftk b/Completion/X/Command/_pdftk index b26deb15f..4029e52fe 100644 --- a/Completion/X/Command/_pdftk +++ b/Completion/X/Command/_pdftk @@ -6,8 +6,7 @@ _pdfwithhandle() _files "$@" -g '(#i)*.pdf' } -local expl -local -a opts operations +local -a expl opts operations opts=(output encrypt_40bit encrypt_128bit allow owner_pw user_pw flatten compress uncompress keep_first_id keep_final_id drop_xfa verbose @@ -22,15 +21,13 @@ case $words[CURRENT-1] in ;; (allow) - #_description permissions expl "permission" - #compadd $expl \ _values -s , permission \ Printing DegradedPrinting ModifyContents Assembly CopyContents \ ScreenReaders ModifyAnnotations FillIn AllFeatures ;; (attach_files) - _files "$@" + _files ;; (fill_form) @@ -51,11 +48,9 @@ case $words[CURRENT-1] in esac && return 0 if [[ -n $words[(r)(${(j:|:)operations})] ]]; then - _description options expl "option" - compadd $@ $expl $opts + _wanted options expl "option" compadd -a opts else - _tags files operations - _alternative \ - 'files:PDF file:_pdfwithhandle' \ - "operations:operation:($operations)" + _alternative \ + 'files:PDF file:_pdfwithhandle' \ + "operations:operation:compadd -a operations" fi diff --git a/Completion/X/Command/_xv b/Completion/X/Command/_xv index 513a953dc..1c35d3a2c 100644 --- a/Completion/X/Command/_xv +++ b/Completion/X/Command/_xv @@ -42,4 +42,4 @@ _x_arguments \ '-gsres:ghostscript resolution' \ '-gsgeom:ghostscript page size' \ '-DEBUG:debug level' \ - '*:picture file:_files -g \*.\(\#i\)\(png\|gif\|jpeg\|jpg\|tiff\|tif\|pbm\|pgm\|ppm\|xbm\|xpm\|ras\(\|t\)\|tga\|rle\|rgb\|bmp\|pcx\|fits\|pm\)\(-.\)' + '*:picture file:_files -g \*.\(\#i\)\(png\|gif\|jpeg\|jpg\|tiff\|tif\|pbm\|pgm\|ppm\|xbm\|xpm\|ras\(\|t\)\|tga\|rle\|rgb\|bmp\|pcx\|fits\|pm\|eps\)\(-.\)' |
