bash – 当路径作为命令输入时,cd到目录(而不是“foo是目录”错误)

我讨厌当bash给我“呃!”一种错误
foo$./bar
-bash: ./bar: is a directory

我曾经喜欢AmigaOS shell,其中“执行”目录只是意味着将其设置为当前目录:

foo$./bar
bar$

在bash中有可能吗? (当然没有无限数量的别名.)

Bash 4.0具有autocd选项.

Official FAQ

There is a new ‘autocd’ option that,
when enabled,causes bash to attempt
to `cd’ to a directory name that is
supplied as the first word of a simple
command.

另外,至少早在2.0之前,请查看man bash中任何版本的Cdpath环境变量.它允许您通过在列出的目录中搜索cd命令中指定的目录来缩短cd命令.

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...