Custom Bash completions for lazy bastards
by bigpresh on Jan.25, 2010, under Linux
At $work, we have a log server, where the current day’s logs from a given machine are stored in, e.g. /logs/machinename/year/month/day/. In a moment of yak shaving, I added a function to my .profile, named cdmachinelogs to allow me to type e.g. cdmachinelogs somemachine, and end up in the appropriate directory.
Now, Bash will automatically tab-complete e.g. “cdm
Enter the following snippet:
complete -W "$(find /log/path -maxdepth 1 -mindepth 1 -type d -printf '%f ')" cdmachinelogs
So, it sets up tab-completion for the cdmachinelogs command, using a list of words obtained by finding each directory name under the path to the logs.
Posted mostly for my own later reference, but also for anyone who might find it useful.
If you liked that post, then try these...
Spammers targetting "techies"?
Extract part of a Subversion repo into a Git repo
February 5th, 2010 on 8:56 pm
cool – thank you..
David
reiki world
February 8th, 2010 on 7:42 pm
A scientific dictatorship is in its final stages of completion.in a row and pretend to be two people, change the name a bit more you lazy bastard.multi ethnic and it crosses all boundaries. you shouldnt bash something you