-
Notifications
You must be signed in to change notification settings - Fork 1
ROADMAP - Bash completion #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Never done a bash completion before so I am going to borrow from the pass project and just rewrite the internals. Apparently we need a script in the folder /usr/share/bash-completion/completions It would appear that all you need to do is supply a bash script that supplies a number of functions |
You'll have to create a new file: /etc/bash_completion.d/foo For a static autocompletion (--help / --verbose for instance) add this:
And the compgen command returns the array of elements from --help, --verbose and --version matching the current word "${cur}":
|
Here is a complete tutorial. Let's have an example of script called admin.sh to which you would like to have autocomplete working.
Note the option shortlist. Calling the script with this option will print out all possible options for this script. And here you have the autocomplete script:
Note that the last argument to complete is the name of the script you want to add autocompletion to. All you need to do is to add your autocomplete script to bashrc as source /path/to/your/autocomplete.sh or copy it to /etc/bash.completion.d |
ROADMAP feature:
Create bash completion script
The text was updated successfully, but these errors were encountered: