fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
ea8e122fa
master
1# `wlr-randr` completions. 2# See: https://gitlab.freedesktop.org/emersion/wlr-randr 3 4function __fish_print_wlr-randr_outputs --argument-names exclude 5if command -q jq 6wlr-randr --json| jq \ 7 --raw-output\ 8 --arg exclude" $exclude " \ 9'.[] | select(.name != $exclude) | "\(.name)\t\(.make), \(.model)"' 10end 11end 12 13function __fish_get_wlr-randr-current_output 14set -l last_output 15set -l tokens( commandline -xpc) 16 17while set -q tokens[ 1 ] 18if test " $tokens [ 1 ] " = --output 19set last_output" $tokens [ 2 ] " 20set -e tokens[ 1 ] 21else if string match -qr --'^--output=' " $tokens [ 1 ] " 22set last_output( string replace -r --'--output=(.*)' '$1' " $tokens [ 1 ] " ) 23end 24 25set -e tokens[ 1 ] 26end 27 28printf "%s" $last_output 29end 30 31function __fish_complete_wlr-randr_modes 32if command -q jq 33set -l output( __fish_get_wlr-randr-current_output ) 34 35wlr-randr --json| jq \ 36 --raw-output\ 37 --arg output" $output " \ 38 --arg preferred_str Preferred\ 39 --arg empty_str'' \ 40'.[] | select(.name == $output) | .modes[] | "\(.width)x\(.height)\t\(if .preferred then $preferred_str else $empty_str end)"' 41end 42end 43 44complete -c wlr-randr -f 45complete -c wlr-randr -s h -l help -d'Show help' 46complete -c wlr-randr -l json -d'Print as JSON' 47complete -c wlr-randr -l dryrun -d'Dry run' 48complete -c wlr-randr -l output -x -d Output -a'(__fish_print_wlr-randr_outputs)' 49complete -c wlr-randr -l on -d'Turn on' 50complete -c wlr-randr -l off -d'Turn off' 51complete -c wlr-randr -l mode -x -d Mode -a'(__fish_complete_wlr-randr_modes)' 52complete -c wlr-randr -l pos -r -d Position 53complete -c wlr-randr -l left-of -x -d'Relative left position' -a'(__fish_print_wlr-randr_outputs (__fish_get_wlr-randr-current_output))' 54complete -c wlr-randr -l right-of -x -d'Relative right position' -a'(__fish_print_wlr-randr_outputs (__fish_get_wlr-randr-current_output))' 55complete -c wlr-randr -l above -x -d'Relative top position' -a'(__fish_print_wlr-randr_outputs (__fish_get_wlr-randr-current_output))' 56complete -c wlr-randr -l below -x -d'Relative bottom position' -a'(__fish_print_wlr-randr_outputs (__fish_get_wlr-randr-current_output))' 57complete -c wlr-randr -l transform -x -d Transformation -a'normal\t 90\t 180\t 270\t flipped\t flipped-90\t flipped-180\t flipped-270\t' 58complete -c wlr-randr -l scale -x -d Scale