]> git.mxchange.org Git - flightgear.git/blob - scripts/completion/fg-completion.bash
better instructions
[flightgear.git] / scripts / completion / fg-completion.bash
1 #!/bin/bash
2 # Tab completion for FlightGear command line options. To use it put
3 # this in your ~/.bashrc file:
4 #
5 #   export FG_HOME=$HOME/.fgfs/
6 #   [ -e $FG_HOME/fg-completion.bash ] && source $FG_HOME/fg-completion.bash
7 #
8 # Defining FG_HOME is only required if you don't like the default
9 # "$HOME/.fgfs/". The script doesn't offer all available airports
10 # for the --airport option, but only those listed in a file
11 # $FG_HOME/airport.list if available, or a short default list otherwise.
12
13 __fgfs_root=${FG_ROOT:-/usr/local/share/FlightGear}
14 __fgfs_home=${FG_HOME:-$HOME/.fgfs}
15 [ -d "$__fgfs_home" ] || mkdir -p "$__fgfs_home"
16
17
18 __fgfs_apt_list="$__fgfs_home/airport.list"
19
20 __fgfs_options="
21         --help
22         --verbose
23         --disable-intro-music
24         --enable-intro-music
25         --units-feet
26         --units-meters
27         --disable-sound
28         --enable-sound
29         --disable-panel
30         --enable-panel
31         --disable-hud
32         --enable-hud
33         --disable-anti-alias-hud
34         --enable-anti-alias-hud
35         --disable-hud-3d
36         --enable-hud-3d
37         --hud-tris
38         --hud-culled
39         --disable-random-objects
40         --enable-random-objects
41         --disable-ai-models
42         --enable-ai-models
43         --disable-freeze
44         --enable-freeze
45         --disable-fuel-freeze
46         --enable-fuel-freeze
47         --disable-clock-freeze
48         --enable-clock-freeze
49         --disable-splash-screen
50         --enable-splash-screen
51         --disable-mouse-pointer
52         --enable-mouse-pointer
53         --fog-disable
54         --fog-fastest
55         --fog-nicest
56         --disable-enhanced-lighting
57         --enable-enhanced-lighting
58         --disable-distance-attenuation
59         --enable-distance-attenuation
60         --disable-specular-highlight
61         --enable-specular-highlight
62         --disable-fullscreen
63         --enable-fullscreen
64         --disable-game-mode
65         --enable-game-mode
66         --shading-flat
67         --shading-smooth
68         --disable-skyblend
69         --enable-skyblend
70         --disable-textures
71         --enable-textures
72         --disable-wireframe
73         --enable-wireframe
74         --notrim
75         --on-ground
76         --in-air
77         --enable-auto-coordination
78         --disable-auto-coordination
79         --show-aircraft
80         --time-match-real
81         --time-match-local
82         --disable-real-weather-fetch
83         --enable-real-weather-fetch
84         --disable-horizon-effect
85         --enable-horizon-effect
86         --enable-clouds
87         --disable-clouds
88         --enable-clouds3d
89         --disable-clouds3d
90         --atc610x
91         --enable-save-on-exit
92         --disable-save-on-exit
93         --ai-scenario=
94         --fg-root=
95         --fg-scenery=
96         --language=
97         --control=
98         --browser-app=
99         --config=
100         --failure=
101         --bpp=
102         --fov=
103         --callsign=
104         --aspect-ratio-multiplier=
105         --geometry=
106         --view-offset=
107         --aircraft=
108         --min-status=
109         --fdm=
110         --aero=
111         --model-hz=
112         --speed=
113         --aircraft-dir=
114         --timeofday=
115         --time-offset=
116         --start-date-sys=
117         --start-date-gmt=
118         --start-date-lat=
119         --airport=
120         --runway=
121         --carrier=
122         --parkpos=
123         --vor=
124         --ndb=
125         --fix=
126         --offset-distance=
127         --offset-azimuth=
128         --lon=
129         --lat=
130         --altitude=
131         --heading=
132         --roll=
133         --pitch=
134         --uBody=
135         --vBody=
136         --wBody=
137         --vc=
138         --mach=
139         --glideslope=
140         --roc=
141         --wp=
142         --flight-plan=
143         --nav1=
144         --nav2=
145         --adf=
146         --dme=
147         --visibility=
148         --visibility-miles=
149         --wind=
150         --turbulence=
151         --ceiling=
152         --multiplay=
153         --proxy=
154         --httpd=
155         --telnet=
156         --jpg-httpd=
157         --generic=
158         --garmin=
159         --joyclient=
160         --jsclient=
161         --native-ctrls=
162         --native-fdm=
163         --native=
164         --nmea=
165         --opengc=
166         --props=
167         --pve=
168         --ray=
169         --rul=
170         --log-level=
171         --trace-read=
172         --trace-write=
173         --season=
174         --vehicle=
175         --prop:
176 "
177
178
179 if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] \
180                 || [ ${BASH_VERSINFO[0]} -gt 2 ]; then
181         __fgfs_nospace="-o nospace"
182 fi
183
184 shopt -s progcomp
185
186
187 __fgfs_ai_scenario() {
188         local i
189         for i in $__fgfs_root/AI/*.xml; do
190                 i=${i%.xml}
191                 echo ${i##*/}
192         done
193 }
194
195
196 __fgfs_aircraft() {
197         local i
198         for i in $__fgfs_root/Aircraft/*/*-set.xml; do
199                 i=${i%-set.xml}
200                 echo ${i##*/}
201         done
202 }
203
204
205 __fgfs_offer() {
206         local i
207         for i in "$@"; do
208                 [ "$i" == "${i%=}" ] && i="$i "
209                 echo "$i"
210         done
211 }
212
213
214 __fgfs_options=$(__fgfs_offer $__fgfs_options)
215
216
217 __fgfs() {
218         COMPREPLY=()
219         local IFS=$'\n'$'\t' cur=${COMP_WORDS[COMP_CWORD]} alt
220
221         case "$cur" in
222         --ai-scenario=*)
223                 alt=$(__fgfs_offer $(__fgfs_ai_scenario))
224                 ;;
225         --aircraft=*|--vehicle=*)
226                 alt=$(__fgfs_offer $(__fgfs_aircraft))
227                 ;;
228         --airport=*)
229                 if [ -e "$__fgfs_apt_list" ]; then
230                         alt=$(cat "$__fgfs_apt_list")
231                 else
232                         alt=$(__fgfs_offer khaf kpao koak kmry knuq ksjc kccr ksns krhv klvk o62 lpma)
233                 fi
234                 ;;
235         --carrier=*)
236                 alt=$(__fgfs_offer Nimitz Eisenhower Foch)
237                 ;;
238         --control=*)
239                 alt=$(__fgfs_offer joystick keyboard mouse)
240                 ;;
241         --failure=*)
242                 alt=$(__fgfs_offer pitot static vacuum electrical)
243                 ;;
244         --fdm=*)
245                 alt=$(__fgfs_offer jsbsim yasim uiuc larcsim ufo magic)
246                 ;;
247         --geometry=*)
248                 alt=$(__fgfs_offer 640x480 800x600 1024x768 1152x864 1600x1200)
249                 ;;
250         --log-level=*)
251                 alt=$(__fgfs_offer bulk debug info warn alert)
252                 ;;
253         --min-status=*)
254                 alt=$(__fgfs_offer alpha beta early-production production)
255                 ;;
256         --parkpos=*)
257                 alt=$(__fgfs_offer cat-1 cat-2 cat-3 cat-4 park-1)
258                 ;;
259         --season=*)
260                 alt=$(__fgfs_offer summer winter)
261                 ;;
262         --timeofday=*)
263                 alt=$(__fgfs_offer real dawn morning noon afternoon dusk evening midnight)
264                 ;;
265         --prop:*)
266                 return
267                 ;;
268         *)
269                 alt="$__fgfs_options"
270                 ;;
271         esac
272
273         COMPREPLY=($(compgen -W "$alt" -- ${cur#*=}))
274 }
275
276
277 complete -o default $__fgfs_nospace -F __fgfs fgfs signs fgfsterra
278