commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
To change to $HOME in that manner you need to set a shell option. In zsh it is auto_cd, hence
setopt -o auto_cd
in bash4 it is autocd, hence
shopt -s autocd
What the option does is allow you to cd to a directory by just entering its name. This also works if the directory name is stored in a variable:
sends you to /var/www/lighttpd.
CAUTION: If a command or function name identical to the directory name exists it takes precedence.
There are 7 alternatives - vote for the best!
If you can do better, submit your command here.
You must be signed in to comment.