2 # Tab completion for FlightGear command line options.
4 # 1. define $FG_HOME (or accept the default "$HOME/.fgfs/")
6 # 2. run this script to build the $FG_HOME/aircraft.list file and repeat this
7 # step whenever you added an aircraft (or maintain the aircraft list manually):
9 # $ $FG_HOME/fg-completion.bash
12 # 3. source this file from your ~/.bashrc:
14 # [ -e $FG_HOME/fg-completion.bash ] && source $FG_HOME/fg-completion.bash
16 __fgfs_scriptname="fg-completion.bash" # adapt this if you renamed this script!
18 __fgfs_root=${FG_ROOT:-/usr/local/share/FlightGear}
19 __fgfs_home=${FG_HOME:-$HOME/.fgfs}
20 [ -d "$__fgfs_home" ] || mkdir -p "$__fgfs_home"
22 __fgfs_ac_list="$__fgfs_home/aircraft.list"
23 __fgfs_apt_list="$__fgfs_home/airport.list"
38 --disable-anti-alias-hud
39 --enable-anti-alias-hud
44 --disable-random-objects
45 --enable-random-objects
52 --disable-clock-freeze
54 --disable-splash-screen
55 --enable-splash-screen
56 --disable-mouse-pointer
57 --enable-mouse-pointer
61 --disable-enhanced-lighting
62 --enable-enhanced-lighting
63 --disable-distance-attenuation
64 --enable-distance-attenuation
65 --disable-specular-highlight
66 --enable-specular-highlight
82 --enable-auto-coordination
83 --disable-auto-coordination
87 --disable-real-weather-fetch
88 --enable-real-weather-fetch
89 --disable-horizon-effect
90 --enable-horizon-effect
97 --disable-save-on-exit
109 --aspect-ratio-multiplier=
184 if [ ${BASH_VERSINFO[0]} -eq 2 ] && [[ ${BASH_VERSINFO[1]} = "05b" ]] \
185 || [ ${BASH_VERSINFO[0]} -gt 2 ]; then
186 __fgfs_nospace="-o nospace"
192 __fgfs_make_ac_list() {
193 ls $__fgfs_root/Aircraft/*/*-set.xml|
196 echo "${i%-set.xml} "
197 done >"$__fgfs_ac_list"
201 if [ "${0##*/}" == "$__fgfs_scriptname" ]; then # run explicitly -- not sourced
202 echo "creating list of available aircraft: $__fgfs_ac_list"
208 if [ ! -e "$__fgfs_ac_list" ]; then
209 echo "$0: creating list of available aircraft: $__fgfs_ac_list"
214 __fgfs_ai_scenario() {
216 for i in $__fgfs_root/AI/*.xml; do
226 [ "$i" == "${i%=}" ] && i="$i "
232 __fgfs_options=$(__fgfs_offer $__fgfs_options)
237 local IFS=$'\n'$'\t' cur=${COMP_WORDS[COMP_CWORD]} alt
241 alt=$(__fgfs_offer $(__fgfs_ai_scenario))
243 --aircraft=*|--vehicle=*)
244 alt=$(cat "$__fgfs_ac_list")
247 if [ -e "$__fgfs_apt_list" ]; then
248 alt=$(cat "$__fgfs_apt_list")
250 alt=$(__fgfs_offer khaf kpao koak kmry knuq ksjc kccr ksns krhv klvk o62 lpma)
254 alt=$(__fgfs_offer Nimitz Eisenhower Foch)
257 alt=$(__fgfs_offer joystick keyboard mouse)
260 alt=$(__fgfs_offer pitot static vacuum electrical)
263 alt=$(__fgfs_offer jsbsim yasim uiuc larcsim ufo magic)
266 alt=$(__fgfs_offer 640x480 800x600 1024x768 1152x864 1600x1200)
269 alt=$(__fgfs_offer bulk debug info warn alert)
272 alt=$(__fgfs_offer alpha beta early-production production)
275 alt=$(__fgfs_offer cat-1 cat-2 cat-3 cat-4 park-1)
278 alt=$(__fgfs_offer summer winter)
281 alt=$(__fgfs_offer real dawn morning noon afternoon dusk evening midnight)
287 alt="$__fgfs_options"
291 COMPREPLY=($(compgen -W "$alt" -- ${cur#*=}))
295 complete -o default $__fgfs_nospace -F __fgfs fgfs signs fgfsterra