Bash – Change directory without typing cd

aliasbashcd-commandcommand line

Is it possible to make bash change directory in command line simply by typing that directory without any commands like cd?

For example is it possible instead of writing this:

$ cd /tmp

I just want to write only this:

$ /tmp

In other words if I call directory as an application then I want to set that directory as a working one.

Best Answer

In bash there is also autocd option. You can enable it by using shopt -s autocd:

pbm@tauri ~ $ shopt -s autocd
pbm@tauri ~ $ django # Now just type this
cd ./django    <- it's done automatically
pbm@tauri ~/django $