PHP developer living in Worthing, UK working for D3R. Starting Android / Java development for fun.
I like shoving little methods in my bash ~/.profile ... to complete the laziness I added tab auto-completion.
Create a method that generates the tab options then use "complete" to assign it to your custom method:# a method which returns all my project dirs via COMPREPLY - note the use of
# compgen and ls /clients within backticks, that's where you want to do
# your own thang
function _clientdirs()
{
local curw
COMPREPLY=()
curw=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=($(compgen -W '`ls /clients`' -- $curw))
return 0
}
# my 'q' shortcut method to run a queue script in one of my projects
function q()
{
if [ $# -eq 1 ]
then
php /clients/$1/core/tools/run_queue.php local
else
php core/tools/run_queue.php local
fi
}
# assigning the complete method to my method
complete -F _clientdirs -o dirnames q
Comments 0 Comments