I have a bunch of directories:
20130118-Cars_Directory
20130118-Bikes_Directory
20130218-Planes_Directory
20130228-Scooters_Directory
Is there any way to change directories in the manner of typing a partial match in the middle of the command.
Ideally, something in the style of cd *Bikes*<TAB>
, and have dash autocomplete the rest?
You can do that by creating an alias for cd and defining a bash completion as your will. See Bach Completion manual.
Here is a step by step guide. I will use "scd" for our new command, but you can use "cd" as well.
1) Editing .bashrc file
2) Creating the alias
Paste this in the final of the ".bashrc" file:
Save and close.
3) Open a new terminal
Or run:
source ~/.bashrc
4) How to use
Just call the command followed by part of the name of the directory you want to go.
scd Bikes<TAB>
Done. Enjoy!
Actually, by coincidence, it turns out that
cd *Bikes*<RETURN>
works without any changes to the system.I am just a little stunned that it didn't require quotes around
*Bikes*
.Try to use the tool called z, it allows what you need, plus it creates a global database of your cd's weighted by frequency and allows you to jump to frequently visited place instantly.
If you have visited the Bikes directory, you can later type
and you will jump there
The answer from desuga works, but it is case sensitive.
If you do not want it to be case sensitive, the
~/.bashrc
file should be: