I hate when bash
gives me "duh!" kind of error:
foo$ ./bar
-bash: ./bar: is a directory
I used to love AmigaOS shell in which "execution" of a directory simply meant setting it as the current directory:
foo$ ./bar
bar$
Is it possible in bash
? (without infinite number of aliases of course.)
Bash 4.0 has the
autocd
option.From the Official FAQ:
Also, take a look at the
CDPATH
environment variable inman bash
for any version since at least as early as 2.0. It allows you to shortencd
commands by searching the listed directories for the directory specified in acd
command.Don't know about bash but this is possible in zsh.
Edit: you could probably handle this in bash the same way ubuntu catches command not found
As documentation for future searches, this is also possible in csh / tcsh, though the name differs:
This value may also be set to verbose, which then echoes the cd commands that are invoked in this manner.