contrib: zsh completion

This commit is contained in:
Vincent Bernat 2020-01-31 08:34:51 +01:00 committed by Gürkan Gür
parent 029ce622c5
commit ce34e2de04
1 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,40 @@
#compdef autorandr
__autorandr_profile () {
declare -a virtual
virtual=("off":"disable all outputs"
"common":"clone at the largest common resolution"
"clone-largest":"clone with the largest resolution"
"horizontal":"stack all connected outputs horizontally"
"vertical":"stack all connected outputs vertically")
_describe -t virtual-profiles "virtual profiles" virtual
__autorandr_saved_profile
}
__autorandr_saved_profile () {
declare -a saved
saved=(${${(f)${:-$(autorandr)}}/ /:})
_describe -t profiles "saved profiles" saved
}
_autorandr () {
local curcontext="$curcontext" state line exclude="-s --save -l --load -r --remove -c --change"
_arguments -C \
"(: -)"{-h,--help}"[get help]" \
"($exclude)"{-c,--change}"[automatically load the first detected profile]" \
"($exclude)"{-d,--default}"[set default profile]:profile:__autorandr_profile" \
"($exclude)"{-l,--load}"[load profile]:profile:__autorandr_profile" \
"($exclude)"{-s,--save}"[save current setup to a profile]:profile: " \
"($exclude)"{-r,--remove}"[remove profile]:profile:__autorandr_saved_profile" \
--batch"[run autorandr for all users]" \
--current"[list current active configurations]" \
--config"[dump current xrandr setup]" \
--debug"[enable verbose output]" \
--dry-run"[don't change anything]" \
--fingerprint"[fingerprint current hardware]" \
--force"[force loading of a profile]" \
--skip-options"[skip xrandr options]:xrandr options:_values -s , options gamma brightness panning transform primary mode pos rate" \
--version"[show version]"
}
_autorandr "$@"