Bash completion

From FlightGear wiki
Revision as of 06:27, 11 March 2014 by Hamster (Talk | contribs) (updated history of original completion script from 2005)

Jump to: navigation, 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.


You can download a completion script for the fgfs-command from [1]. The completion script is called "fgfs". Usage documents the application of that script.

There are two ways of installing a 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/ )
  • 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


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. The code can be found in the flightgear repository on github in the scripts/completion directory.
  • 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