ZSH Gem #17: Changing directories with auto_cd
This is probably the shortest tip of this series. I only want to show you a ZSH-specific shorthand for changing directories.
The ZSH option AUTO_CD
makes it possible to change directories by just writing their names without using cd
. This might be interesting for those of you who always want to type as few characters as possible. If you are one of those, just activate the option:
setopt auto_cd
You will still be able to use the normal cd
syntax, but now you can also switch the directories by writing the directory name only. For instance, to change to the parent directory, just write ..
, hit enter and there you go. To go into the subdirectory bar inside the subdirectory foo, write foo/bar
. Pretty easy. it's the same as cd
just without cd
.
Personally, I use this syntax rarely, but that's not because I don't find it useful. It's just that I'm used to write cd
and I often have already typed these two characters before I remember that I wanted to use the shorter syntax. But I guess, some of you might do better and speed their workflow up a little by using this shorthand directory switching syntax extensively. :-)
Read more about auto_cd: