ZSH Gem #17: Changing directories with auto_cd

Posted by | Comment (1) | Trackbacks (0)

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. smile

Read more about auto_cd:

Trackbacks

No Trackbacks for this entry.

Comments

There have been 1 comments submitted yet. Add one as well!
Fabien
Fabien wrote on : (permalink)

Indeed, I’ve been using autocd for almost 15 years, now I couldn’t live without it, it’s just so natural. Thanks for the great posts, although I’m a long-term zsh user I’m learning so much!

Write a comment:

HTML-Tags will be converted to Entities.
Textile-formatting allowed
Standard emoticons like :-) and ;-) are converted to images.
Design and Code Copyright © 2010-2017 Janek Bevendorff Content on this site is published under the terms of the GNU Free Documentation License (GFDL). You may redistribute content only in compliance with these terms. tweetbackcheck