我经常必须到cd
一个目录并ls
查看目录列表。可以一次性完成吗,以便我可以添加.bashrc
为别名。我在谷歌上搜索,有一些答案,但不完整。
我认为这意味着您希望在ls
运行后仍然在目录中,如果没有,只需ls
将目录作为参数运行。
cl() {
cd "$@" && ls
}
Run Code Online (Sandbox Code Playgroud)
foo$ mkdir bar
foo$ > bar/baz
foo$ > bar/qux
foo$ cl bar
baz qux
bar$
Run Code Online (Sandbox Code Playgroud)