From 3ce6f8ca91bd28e980943f9346ce6efcbee145b8 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Mon, 21 Feb 2022 22:38:53 +0100 Subject: [PATCH] Add Bash completion script Fixes #2930 Refs #3012 --- app/data/bash-completion/scrcpy | 121 ++++++++++++++++++++++++++++++++ app/meson.build | 2 + 2 files changed, 123 insertions(+) create mode 100644 app/data/bash-completion/scrcpy diff --git a/app/data/bash-completion/scrcpy b/app/data/bash-completion/scrcpy new file mode 100644 index 00000000..464bc532 --- /dev/null +++ b/app/data/bash-completion/scrcpy @@ -0,0 +1,121 @@ +_scrcpy() { + local cur prev words cword + local opts=" + --always-on-top + -b --bit-rate= + --codec-options= + --crop= + -d --select-usb + --disable-screensaver + --display= + --display-buffer= + -e --select-tcpip + --encoder= + --force-adb-forward + --forward-all-clicks + -f --fullscreen + -K --hid-keyboard + -h --help + --legacy-paste + --lock-video-orientation + --lock-video-orientation= + --max-fps= + -M --hid-mouse + -m --max-size= + --no-cleanup + --no-clipboard-on-error + --no-downsize-on-error + -n --no-control + -N --no-display + --no-key-repeat + --no-mipmaps + --otg + -p --port= + --power-off-on-close + --prefer-text + --print-fps + --push-target= + --raw-key-events + -r --record= + --record-format= + --render-driver= + --rotation= + -s --serial= + --shortcut-mod= + -S --turn-screen-off + -t --show-touches + --tcpip + --tcpip= + --tunnel-host= + --tunnel-port= + --v4l2-buffer= + --v4l2-sink= + -V --verbosity= + -v --version + -w --stay-awake + --window-borderless + --window-title= + --window-x= + --window-y= + --window-width= + --window-height=" + + _init_completion -s || return + + case "$prev" in + --lock-video-orientation) + COMPREPLY=($(compgen -W 'unlocked initial 0 1 2 3' -- "$cur")) + return + ;; + -r|--record) + COMPREPLY=($(compgen -f -- "$cur")) + return + ;; + --record-format) + COMPREPLY=($(compgen -W 'mkv mp4' -- "$cur")) + return + ;; + --render-driver) + COMPREPLY=($(compgen -W 'direct3d opengl opengles2 opengles metal software' -- "$cur")) + return + ;; + --rotation) + COMPREPLY=($(compgen -W '0 1 2 3' -- "$cur")) + return + ;; + --shortcut-mod) + # Only auto-complete a single key + COMPREPLY=($(compgen -W 'lctrl rctrl lalt ralt lsuper rsuper' -- "$cur")) + return + ;; + -V|--verbosity) + COMPREPLY=($(compgen -W 'verbose debug info warn error' -- "$cur")) + return + ;; + -b|--bitrate \ + |--codec-options \ + |--crop \ + |--display \ + |--display-buffer \ + |--encoder \ + |--max-fps \ + |-m|--max-size \ + |-p|--port \ + |--push-target \ + |-s|--serial \ + |--tunnel-host \ + |--tunnel-port \ + |--v4l2-buffer \ + |--v4l2-sink \ + |--tcpip \ + |--window-*) + # Option accepting an argument, but nothing to auto-complete + return + ;; + esac + + COMPREPLY=($(compgen -W "$opts" -- "$cur")) + [[ $COMPREPLY == *= ]] && compopt -o nospace +} + +complete -F _scrcpy scrcpy diff --git a/app/meson.build b/app/meson.build index 95a92da2..e34b1893 100644 --- a/app/meson.build +++ b/app/meson.build @@ -229,6 +229,8 @@ install_data('data/icon.png', install_dir: 'share/icons/hicolor/256x256/apps') install_data('data/zsh-completion/_scrcpy', install_dir: 'share/zsh/site-functions') +install_data('data/bash-completion/scrcpy', + install_dir: 'share/bash-completion/completions') ### TESTS