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.
cool – thank you..
David
reiki world
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