Basic tab completion for perlbrew.
This completion script, executes perlbrew list
and offers completions for all the perlbrew
perls and libraries installations you have available.
$ perlbrew use <tab>
perl-5.10.1
perl-5.20.2
perl-5.20.2@workflow
...
And the bash
completion functionality even assists, when you specify more of your targets
$ perlbrew use perl-5.20<tab>
perl-5.20.2
perl-5.20.2@workflow
...
$ curl https://raw.githubusercontent.com/jonasbn/bash_completion_perlbrew/master/perlbrew > perlbrew
Where your completions are located might vary.
If you want to install them for your personal use, do the following.
Create the file: ~/.bash_completion
, containing the code below:
for bcfile in ~/.bash_completion.d/* ; do
. $bcfile
done
Ref: ServerFault.com: Standard place for user defined bash_completion.d scripts?
Create a directory for your completions:
$ mkdir ~/.bash_completion.d
Copy your completions into the newly created directory:
$ cp perlbrew ~/.bash_completion.d/
Start a new shell and you should be good to go.
Based on an introduction to bash
completions on Debian.
$ sudo cp perlbrew /etc/bash_completion.d/
This assumes you are using Homebrew
Do note that paths vary based on whether you are using bash
3 or 4
$ cp perlbrew /usr/local/etc/bash_completion.d/
And to activate right away:
$ source /usr/local/etc/bash_completion.d/perlbrew
$ cp perlbrew /usr/local/share/bash-completion/completions/
And to activate right away:
$ source /usr/local/share/bash-completion/completions/perlbrew
I have a huge list of perlbrew
library installations and I tend to keep the names long and descriptive, so it seemed like tab completion was an interesting alternative to the flow breaking copy-pasting and error prone typing away.
The programmatic capabilities of bash
are truly powerful and useful and can be put to good use in use-cases like this.
A more elaborate piece of documentation on bash
completions is available from The Linux Documentation Project in the Advanced Bash-Scripting Guide.
From the GNU Documentation.
Good two-part article, "An Introduction to Bash Completion": Part 1 and Part 2.
Please note that this experimental implementation has only been tested with bash
version 3.
The most comprehensive collection of bash
completions I have come across is the one from the Debian Linux distribution. It is also the one offered for OSX via Homebrew.
This is made available under the MIT license, see separate license file.
©️ jonasbn 2016-2020