Skip to content

Commit 3ce6f8c

Browse files
committed
Add Bash completion script
Fixes #2930 <#2930> Refs #3012 <#3012>
1 parent 2695378 commit 3ce6f8c

File tree

2 files changed

+123
-0
lines changed

2 files changed

+123
-0
lines changed

app/data/bash-completion/scrcpy

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
_scrcpy() {
2+
local cur prev words cword
3+
local opts="
4+
--always-on-top
5+
-b --bit-rate=
6+
--codec-options=
7+
--crop=
8+
-d --select-usb
9+
--disable-screensaver
10+
--display=
11+
--display-buffer=
12+
-e --select-tcpip
13+
--encoder=
14+
--force-adb-forward
15+
--forward-all-clicks
16+
-f --fullscreen
17+
-K --hid-keyboard
18+
-h --help
19+
--legacy-paste
20+
--lock-video-orientation
21+
--lock-video-orientation=
22+
--max-fps=
23+
-M --hid-mouse
24+
-m --max-size=
25+
--no-cleanup
26+
--no-clipboard-on-error
27+
--no-downsize-on-error
28+
-n --no-control
29+
-N --no-display
30+
--no-key-repeat
31+
--no-mipmaps
32+
--otg
33+
-p --port=
34+
--power-off-on-close
35+
--prefer-text
36+
--print-fps
37+
--push-target=
38+
--raw-key-events
39+
-r --record=
40+
--record-format=
41+
--render-driver=
42+
--rotation=
43+
-s --serial=
44+
--shortcut-mod=
45+
-S --turn-screen-off
46+
-t --show-touches
47+
--tcpip
48+
--tcpip=
49+
--tunnel-host=
50+
--tunnel-port=
51+
--v4l2-buffer=
52+
--v4l2-sink=
53+
-V --verbosity=
54+
-v --version
55+
-w --stay-awake
56+
--window-borderless
57+
--window-title=
58+
--window-x=
59+
--window-y=
60+
--window-width=
61+
--window-height="
62+
63+
_init_completion -s || return
64+
65+
case "$prev" in
66+
--lock-video-orientation)
67+
COMPREPLY=($(compgen -W 'unlocked initial 0 1 2 3' -- "$cur"))
68+
return
69+
;;
70+
-r|--record)
71+
COMPREPLY=($(compgen -f -- "$cur"))
72+
return
73+
;;
74+
--record-format)
75+
COMPREPLY=($(compgen -W 'mkv mp4' -- "$cur"))
76+
return
77+
;;
78+
--render-driver)
79+
COMPREPLY=($(compgen -W 'direct3d opengl opengles2 opengles metal software' -- "$cur"))
80+
return
81+
;;
82+
--rotation)
83+
COMPREPLY=($(compgen -W '0 1 2 3' -- "$cur"))
84+
return
85+
;;
86+
--shortcut-mod)
87+
# Only auto-complete a single key
88+
COMPREPLY=($(compgen -W 'lctrl rctrl lalt ralt lsuper rsuper' -- "$cur"))
89+
return
90+
;;
91+
-V|--verbosity)
92+
COMPREPLY=($(compgen -W 'verbose debug info warn error' -- "$cur"))
93+
return
94+
;;
95+
-b|--bitrate \
96+
|--codec-options \
97+
|--crop \
98+
|--display \
99+
|--display-buffer \
100+
|--encoder \
101+
|--max-fps \
102+
|-m|--max-size \
103+
|-p|--port \
104+
|--push-target \
105+
|-s|--serial \
106+
|--tunnel-host \
107+
|--tunnel-port \
108+
|--v4l2-buffer \
109+
|--v4l2-sink \
110+
|--tcpip \
111+
|--window-*)
112+
# Option accepting an argument, but nothing to auto-complete
113+
return
114+
;;
115+
esac
116+
117+
COMPREPLY=($(compgen -W "$opts" -- "$cur"))
118+
[[ $COMPREPLY == *= ]] && compopt -o nospace
119+
}
120+
121+
complete -F _scrcpy scrcpy

app/meson.build

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ install_data('data/icon.png',
229229
install_dir: 'share/icons/hicolor/256x256/apps')
230230
install_data('data/zsh-completion/_scrcpy',
231231
install_dir: 'share/zsh/site-functions')
232+
install_data('data/bash-completion/scrcpy',
233+
install_dir: 'share/bash-completion/completions')
232234

233235

234236
### TESTS

0 commit comments

Comments
 (0)