Tell me more ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

For example if a directory 'blob' exists and I just type 'blob[return]' then the system cds into the blob directory for me.

In Linux (Ubuntu) I can add shopt -s autocd to my .bashrc file, but on OS X this gives an error: -bash: shopt: autocd: invalid shell option name

share|improve this question
Congrats on 1k. – Undo Jun 2 at 23:09
congrats on 1.3rd of the way for you too ;) – Michael Durrant Jun 2 at 23:31
Yes, I'm 3k on SO and 2k on MSO, so I have my share of privileges elsewhere :) – Undo Jun 2 at 23:52

2 Answers

up vote 14 down vote accepted

autocd was added in Bash 4.0. You can install Bash 4 with Homebrew:

  • brew install bash
  • Add /usr/local/bin/bash to /etc/shells
  • chsh -s /usr/local/bin/bash
  • Open a new login shell (or a tab by default in Terminal or iTerm 2) and check echo $BASH_VERSION
share|improve this answer
1  
Great answer. Bash 4 is also available in MacPorts:subbing sudo port install bash into your step 1 works as well. – ephsmith Jul 3 '12 at 17:39
I did the above. I ended up with bash 4.2.29 and I made the changes to /etc/shells and did the cssh but no joy – Michael Durrant Jul 9 '12 at 2:51
@MichaelDurrant I edited the answer. bash -version would be the first version on $PATH. Did you try echo $BASH_VERSION? – Lauri Ranta Jul 9 '12 at 4:44
it works if i run the command directly /usr/local/bin/bash - i get v4.2 but how do I make that my default shell for a new window? – Michael Durrant Jul 10 '12 at 2:53
1  
@MichaelDurrant Is your terminal application set to open with something like /usr/bin/login or login -fp $USER in the preferences? – Lauri Ranta Jul 10 '12 at 12:02
show 3 more comments

The output of shopt -p can be of some help here. It prints a list of settable options. Sadly, on Lion, autocd is not one of them (see excerpt below).

Edit Lauri's answer above has a solution for updating your shell to include autocd

$ shopt -p
shopt -u cdable_vars
shopt -u cdspell
shopt -u checkhash
shopt -s checkwinsize
shopt -s cmdhist
shopt -u compat31
shopt -u dotglob
shopt -u execfail
shopt -s expand_aliases
shopt -u extdebug
shopt -u extglob
shopt -s extquote
shopt -u failglob
shopt -s force_fignore
shopt -u gnu_errfmt
shopt -u histappend
shopt -u histreedit
shopt -u histverify
shopt -s hostcomplete
shopt -u huponexit
shopt -s interactive_comments
shopt -u lithist
shopt -s login_shell
shopt -u mailwarn
shopt -u no_empty_cmd_completion
shopt -u nocaseglob
shopt -u nocasematch
shopt -u nullglob
shopt -s progcomp
shopt -s promptvars
shopt -u restricted_shell
shopt -u shift_verbose
shopt -s sourcepath
shopt -u xpg_echo
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.