Bash completion

From FlightGear wiki
Jump to navigation Jump to search

bash completion is an extension for the bash shell - normally used on Unix-like systems - that tries to auto-complete the command you are currently typing, when Tab is pressed. Pressing Tab twice shows a list of all possible completions if more than one is available.

By default the bash-shell is only able to complete the names of the executables (like "fgfs", "terrasync"), but can be extended by third-party scripts to further complete options (e.g. --enable-fullscreen ) and key/value pairs (e.g. --aircraft=seahawk ) specific to some executable.


A completion script is contained in the source tree of FlightGear. It is located at $FG_SRC/scripts/completion/fg-completion.bash. Usage documents the application of that script.

There are two ways of installing the bash-completion script:

Local Installation

  • put the completion script somewhere in your home directory
  • append
    source path/to/completion/script
    to your .bashrc file
  • restart your shell

Global Installation

  • put the completion script in the global bash-completion directory (on ArchLinux: /usr/share/bash-completion/completions/ ) and rename it to "fgfs"
  • restart your shell


The completion script is able to auto-complete all options listed in

fgfs --help --verbose

of your local version of FlightGear.

To test the completion of options type

fgfs -

and twice Tab . You should see a list of all options and keys available in your FlightGear installation. If not, you did not restart the shell after installing the script, the script is not installed correctly or you have a serious problem with your FlightGear installation (or you found an unknown bug in the completion script!).


The auto-completion procedure needs access to FGDATA to complete values like airport codes, parking positions or aircrafts.

The completion script will use the first of the following 3 methods that yields a valid path:

  • --fg-root, --fg-scenery, --fg-aircraft written in the command line you are currently typing, or in ~/.fgfsrc
  • $FG_ROOT, $FG_SCENERY, $FG_AIRCRAFT environment variables
  • a hardcoded list of paths


The names of aircrafts will be completed after the --aircraft key. The aircraft directory is detected the same way as FG_ROOT. First the script tries to find --fg-aircraft on the command line and in ~/.fgfsrc, then checks the $FG_AIRCRAFT environment variable, and if everything fails uses $FG_ROOT/Aircraft.


Carriers (like the Nimitz, Foch, and others) are not contained in the scenery, but included in scenarios. Auto-completion for --carrier values will offer the names of all carriers, that are contained in the loaded scenarios (specified with the --ai-scenario=... key). Multiple scenarios can be loaded at once.


The values of --runway can be completed. The result depends on the airport that is selected. The scenery around the airport has to be installed for that completion.

Parking Positions

Completion for the --parkpos key is available. If a carrier is specified, the parking positions will be read from the scenario of the carrier. Else, the result depends on the airport that is selected. Completion is only possible for airports with installed scenery.

Navaids, Fixes

Completion is also available for the values of the --vor, --ndb and --fix keys.

If --vor/--ndb is given, auto-completion will work for the --vor-frequency/--ndb-frequency key, and offer the frequencies of navigation aids with the given name.


  • According to the mailing list, bash completion has been available for Flightgear since 2005 (at this time completion functionality has been really rare), but not updated since 2008.
  • in 2014 User:Hamster has announced a new completion script in the forums, which adds functionality for completion of runways, parking positions and some more. This version has now replaced the previous script in the source tree.