Bash – Changing directories with Bash

autocompletebashcd-command

I was wondering if there was an easier way to pick directories to cd to within one's current directory.

For example, is there a way to just get a numbered list of the current directory and be able to do cd 1, cd 2, cd 3, etc.
Is there some other way to easily cd between sub directories in one's current directory?

Best Answer

If you set the autocd option in your ~/.bashrc you can change directories just by typing the name. Combined with Tab completion, you have only to type the first, unique characters and then hit Tab to move to your desired directory.

From the manual:

If set, a command name that is the name of a directory is executed as if it were the argument to the cd command. This option is only used by interactive shells.

Add the option to your ~/.bashrc with:

shopt -s autocd 

If you use Zsh, set the option with:

setopt autocd 
Related Question