DEV Community 👩‍💻👨‍💻

Seiya Izumi
Seiya Izumi

Posted on

How to use bash "autocd" option in Mac

Run this command to check the version of Bash installed in your Mac.

$ /bin/bash --version  
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin14)    
Copyright (C) 2007 Free Software Foundation, Inc.  

If it is not 4.0 and more, you should install the newer one with homebrew

$ brew update
$ brew install bash

Make sure where the new Bash has been installed into and if it has been updated or not. Finally, use echo and write the path of it into /etc/shells

$ which bash
...
$ /usr/local/bin/bash --version
...
$ echo /usr/local/bin/bash | sudo tee -a /etc/shells
...

Last but not the last, use chsh command to change the current shell, and check the result of shopt -p sure has autocd

$ chsh -s /usr/local/bin/bash
...
$ shopt -p
...

Top comments (0)

Want to Create an Account?
Now it's your turn!
 
🗒 Share a tutorial
🤔 Reflect on your coding journey
❓ Ask a question

Create an account to join hundreds of thousands of DEV members on their journey.