I have implemented some perl scripts and in some cases i have to pass some command line args into my program.Usability perspective i have decided to add some bash completion script
into my project.But now i am stuck on where to put my script to work it as expected.Please let me know where can i put my bash completion script
Custom Perl Scripts location
C:\scripts\tool\bin\ktools.pl
also add bin
path to the system variable.
I have put my auto complete scripts in
C:\scripts\tool\bin\etc\bash_completion.d\ktools\foo
Bash Completion Script
_foo()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="--help --verbose --version"
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
complete -F _foo ktools
Command should be auto suggested when user type ktools -- + press tab
in command line or git bash.
I'm pretty sure you need to source it into your .bashrc
(basically include it).
Open ~/.bashrc
and write (you might need to create it if it doesn't exists)
source your_bash_file
Then, in your terminal, "refresh" by doing
source ~/.bashrc
and it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With