autocd
was added in bash 4.0. You can install a newer version of bash with Homebrew and then change the default login shell with chsh
:
brew install bash;echo /usr/local/bin/bash|sudo tee -a /etc/shells;chsh -s /usr/local/bin/bash
After you open a new login shell (or a tab by default in Terminal or iTerm 2), echo $BASH_VERSION
should print something like 4.2.45(2)-release
.
Terminal and iTerm 2 open new shells as login shells by default, so bash reads ~/.bash_profile
but not ~/.bashrc
. If you don't source ~/.bashrc
from ~/.bash_profile
or anything, add shopt -s autocd
to ~/.bash_profile
instead of ~/.bashrc
.