Board index FlightGear Development New features

bash-completion

Discussion and requests for new features. Please note that FlightGear developers are volunteers and may or may not be able to consider these requests.

bash-completion

Postby hamster » Sun Mar 09, 2014 2:23 pm

Hi everybody!

I have written a bash-completion script that supports completion for all keys from
Code: Select all
fgfs --help --verbose

and completion for values of:
    --ai-scenario
    --aircraft
    --airport
    --carrier
    --runway
    --parkpos
    --ndb, --vor, --fix
    --vor-frequency, --ndb-frequency
    --timeofday, --season
and some others.

Check it out from: https://gitorious.org/fg-bashcomp

The settings have influence on each other. If you for example change paths in the command line (e.g. --fg-aircraft), then this will also change the search path of the autocompletion for the "--aircraft=" values.
The autocompletion first looks at the settings already written in the command line, then in ~/.fgfsrc and at last at the environment variables $FG_ROOT, $FG_SCENERY, $FG_AIRCRAFT (except some hardcoded guesses for FG_ROOT if everything else fails), to offer only valid results.

To install it, you have to put the file "fgfs" in the folder /usr/share/bash-completion/completions/ and restart your shell.
Why not giving it a try and saving time in the command line? :wink:

Please tell me, if your distribution's default FG_ROOT is not contained in /usr{/local,}/share{/games,}/{F,f}light{G,g}ear{/data,} :lol:

hamster
hamster
 
Posts: 26
Joined: Tue Sep 28, 2010 7:50 pm
Location: Germany
Callsign: hamster
Version: Git
OS: Arch Linux

Re: bash-completion

Postby Hooray » Sun Mar 09, 2014 4:13 pm

good job, you should open a merge request so that this can be committed to the contrib directory
And please also feel free to document the whole thing by creating a new wiki article, you may also want to add a paragraph about it to the upcoming newsletter (see my signature)
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: bash-completion

Postby hamster » Mon Mar 10, 2014 2:13 am

I have just created the wiki-article: http://wiki.flightgear.org/Bash_completion
hamster
 
Posts: 26
Joined: Tue Sep 28, 2010 7:50 pm
Location: Germany
Callsign: hamster
Version: Git
OS: Arch Linux

Re: bash-completion

Postby Philosopher » Mon Mar 10, 2014 1:43 pm

Wow, looks like excellent work! I'll have to clone and source it ASAP.

Btw: standard Mac OS X installation is in {~,}/Applications/FlightGear.app/Contents/Resources/data (I used to name it with underscores after for versions, e.g. FlightGear_2.8.app, but I don't know if you can support that).
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: bash-completion

Postby Hooray » Mon Mar 10, 2014 4:43 pm

hamster wrote in Mon Mar 10, 2014 2:13 am:I have just created the wiki-article: http://wiki.flightgear.org/Bash_completion


good job, if you haven't already, feel free to add a link to your article to the upcoming newsletter
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: bash-completion

Postby hamster » Mon Mar 10, 2014 11:56 pm

@Hooray:
OK, I just added a short text to the next newsletter.
I am not really sure, what you meant with the contrib directory. Is it the 3rdparty directory in the flightgear repository?

@Philosopher:
The standard Mac OS X installation path is included now. If you are using a custom path, then you probably have the environment variable FG_ROOT or --fg-root in the command line or in ~/.fgfsrc. In that case, the script should work out of the box.

If this naming pattern is standard for installations of several different versions then I will add that, but before that I will need to implement handling of different versions of FlightGear in the filesystem first.


Thanks for your comments! Development is much more fun with feedback!
hamster
 
Posts: 26
Joined: Tue Sep 28, 2010 7:50 pm
Location: Germany
Callsign: hamster
Version: Git
OS: Arch Linux

Re: bash-completion

Postby Hooray » Tue Mar 11, 2014 12:18 am

there used to be some kind of "contrib" directory somewhere - in $FG_SRC, there's still "utils" which would seem like an appropriate place for this, and it could be integrated with the cmake build system so that the script gets installed automatically
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: bash-completion

Postby Torsten » Tue Mar 11, 2014 7:15 am

flightgear.org - where development happens.
User avatar
Torsten
 
Posts: 648
Joined: Fri Feb 01, 2008 10:22 pm
Location: near Hamburg, Germany
Callsign: offline
Version: next
OS: Linux

Re: bash-completion

Postby Hooray » Tue Mar 11, 2014 8:15 am

yeah, the OP is obviously aware of it according to the article: http://wiki.flightgear.org/Bash_completion
And like he correctly said: this hasn't been maintained in over half a decade apparently...
I'm sure that mfranz will appreciate any updates/contributions related to this.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: bash-completion

Postby hamster » Wed Mar 12, 2014 9:12 pm

OK, we now have found the perfect place for the script: "scripts/completion/"

I checked my script against the version from 2008.
The new script pretty much implements all of the functionality of the previous version (with the exception of the geometry option, where I am not sure whether I should add suggestions or not) and adds functionality like overwriting paths, completion for runways, parking positions and navaids. Furthermore it does not use static lists for options, airports and carriers, but creates them dynamically.

Now, should I open a merge request for replacing the existing script, or just add it under a different name?
hamster
 
Posts: 26
Joined: Tue Sep 28, 2010 7:50 pm
Location: Germany
Callsign: hamster
Version: Git
OS: Arch Linux

Re: bash-completion

Postby Hooray » Wed Mar 12, 2014 9:40 pm

If you can, I'd suggest to get in touch with mfranz (also his forum handle) and ask for some feedback, so that he can suggest how to proceed.
If he doesn't respond, don't replace his script in the merge request, but add yours as an alternative in the meantime.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: bash-completion

Postby hamster » Thu Oct 09, 2014 12:53 pm

OK, my completion script has now replaced the previous version by mfranz, who agreed with the replacement.

If you want bash completion enabled for your distribution, you can now ask the package maintainer to install scripts/completion/fg-completion.bash to the bash-completion directory of your distribution.

Thanks to Hooray for helping, and Thorsten Dreyer who merged the script in the source tree.
hamster
 
Posts: 26
Joined: Tue Sep 28, 2010 7:50 pm
Location: Germany
Callsign: hamster
Version: Git
OS: Arch Linux

Re: bash-completion

Postby hamster » Fri Oct 10, 2014 1:18 am

Bash completion for "fgfs" is now enabled by default in ArchLinux. Until the next version of FlightGear gets out it will still use the old script, since the new version has only been commited recently and is not yet available in the source tree of FlightGear 3.0, but the update to 3.2 will introduce the new script then.
hamster
 
Posts: 26
Joined: Tue Sep 28, 2010 7:50 pm
Location: Germany
Callsign: hamster
Version: Git
OS: Arch Linux


Return to New features

Who is online

Users browsing this forum: No registered users and 4 guests