Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BASH blank alias to 'cd'

I am a happy BASH user. I do not want to switch to another shell (in this case ZSH).

ZSH has this ability to change a directory without necessarily typing:

cd /to/a/directory

What would be the correct alias (or maybe BASH function) to change directories without having to type cd?

On my above example, moving to /to/a/directory would be done like this:

/to/a/directory

I have tried:

alias ''='cd '
alias ""='cd '
alias " "='cd '

Any ideas?

like image 837
alfredodeza Avatar asked May 20 '09 20:05

alfredodeza


2 Answers

It's an option added in version 4.0 of Bash. You can set it with:

$ shopt -s autocd

Put that in your .bashrc file to enable it always.

like image 123
mipadi Avatar answered Nov 09 '22 03:11

mipadi


I don't think you'll be able to have a "blank" alias, it doesn't really make sense..

bash version 4.0 added the autocd option, which is set by running shopt -s autocd (as mipadi answered)

There is no such option in previous versions of bash, annoying.

like image 22
dbr Avatar answered Nov 09 '22 02:11

dbr