Skip to content
0.2.0-dev Download ZIP
148 lines ·4.2 KB Raw
1# Bash completion for the Godot editor
2# To use it, install this file in `/etc/bash_completion.d` then restart your shell.
3# You can also `source` this file directly in your shell startup file.
4#
5# Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md).
6# Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.
7#
8# Permission is hereby granted, free of charge, to any person obtaining a copy
9# of this software and associated documentation files (the "Software"), to deal
10# in the Software without restriction, including without limitation the rights
11# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12# copies of the Software, and to permit persons to whom the Software is
13# furnished to do so, subject to the following conditions:
14#
15# The above copyright notice and this permission notice shall be included in all
16# copies or substantial portions of the Software.
17#
18# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24# SOFTWARE.
25
26_complete_godot_options() {
27 # Since Bash doesn't support option descriptions in autocompletion,
28 # only display long options to be more descriptive.
29 # shellcheck disable=SC2207
30 COMPREPLY=($(compgen -W " \
31--help
32--version
33--verbose
34--quiet
35--editor
36--project-manager
37--debug-server
38--quit
39--language
40--path
41--main-pack
42--render-thread
43--remote-fs
44--remote-fs-password
45--audio-driver
46--audio-output-latency
47--display-driver
48--rendering-method
49--rendering-driver
50--gpu-index
51--text-driver
52--tablet-driver
53--headless
54--log-file
55--write-movie
56--fullscreen
57--maximized
58--windowed
59--always-on-top
60--resolution
61--position
62--single-window
63--xr-mode
64--debug
65--breakpoints
66--profiling
67--gpu-profile
68--gpu-validation
69--gpu-abort
70--remote-debug
71--debug-collisions
72--debug-navigation
73--debug-stringnames
74--max-fps
75--frame-delay
76--time-scale
77--disable-vsync
78--disable-render-loop
79--disable-crash-handler
80--fixed-fps
81--print-fps
82--script
83--check-only
84--export-release
85--export-debug
86--export-pack
87--convert-3to4
88--validate-conversion-3to4
89--doctool
90--no-docbase
91--build-solutions
92--dump-gdextension-interface
93--dump-extension-api
94--benchmark
95--benchmark-file
96--test
97" -- "$1"))
98}
99
100_complete_godot_bash() {
101 local cur="${COMP_WORDS[$COMP_CWORD]}" prev
102
103 # Complete options or the positional argument.
104 if [[ $cur == -* ]]; then
105 _complete_godot_options "$cur"
106 else
107 local IFS=$'\n\t'
108 # shellcheck disable=SC2207
109 COMPREPLY=($(compgen -f -X "!*.@(scn|tscn|escn|godot)" -- "$cur"))
110 fi
111
112 # If the array is accessed out of bounds (which will happen for the first argument),
113 # `$prev` will be an empty string and won't match any of the conditions below.
114 prev="${COMP_WORDS[$((COMP_CWORD-1))]}"
115
116 # Complete option values.
117 if [[ $prev == "--render-thread" ]]; then
118 local IFS=$' \n\t'
119 # shellcheck disable=SC2207
120 COMPREPLY=($(compgen -W "unsafe safe separate" -- "$cur"))
121 elif [[ $prev == "--rendering-method" ]]; then
122 local IFS=$' \n\t'
123 # shellcheck disable=SC2207
124 COMPREPLY=($(compgen -W "forward_plus mobile gl_compatibility" -- "$cur"))
125 elif [[ $prev == "--rendering-driver" ]]; then
126 local IFS=$' \n\t'
127 # shellcheck disable=SC2207
128 COMPREPLY=($(compgen -W "vulkan opengl3 dummy" -- "$cur"))
129 elif [[ $prev == "--xr-mode" ]]; then
130 local IFS=$' \n\t'
131 # shellcheck disable=SC2207
132 COMPREPLY=($(compgen -W "default off on" -- "$cur"))
133 elif [[ $prev == "--path" || $prev == "--doctool" ]]; then
134 local IFS=$'\n\t'
135 # shellcheck disable=SC2207
136 COMPREPLY=($(compgen -d -- "$cur"))
137 elif [[ $prev == "--main-pack" ]]; then
138 local IFS=$'\n\t'
139 # shellcheck disable=SC2207
140 COMPREPLY=($(compgen -f -X "!*.@(pck|zip)" -- "$cur"))
141 elif [[ $prev == "-s" || $prev == "--script" ]]; then
142 local IFS=$'\n\t'
143 # shellcheck disable=SC2207
144 COMPREPLY=($(compgen -f -X "!*.gd" -- "$cur"))
145 fi
146}
147
148complete -o filenames -F _complete_godot_bash godot