有没有办法在zsh中使用autocd切换到目录后自动执行ls?
Is there way to automatically ls after changing into a directory using autocd in zsh?
我在我的 .zshrc
中设置了 autocd
,它按预期工作,但我想在每次使用它时自动 运行 ls
。我可以这样做:
function cd {
builtin cd "$@" && ls --color=auto
}
每次我显式使用 'cd' 时 到 ls
,但如果我只键入目录名称,我希望它也能工作。
这可能吗?谢谢。
如果您使用预定义名称 chpwd
定义了一个函数,它会在您的工作目录每次更改时执行。
zsh 手册页的“特殊功能”一章中描述了此行为
我在我的 .zshrc
中设置了 autocd
,它按预期工作,但我想在每次使用它时自动 运行 ls
。我可以这样做:
function cd {
builtin cd "$@" && ls --color=auto
}
每次我显式使用 'cd' 时 到 ls
,但如果我只键入目录名称,我希望它也能工作。
这可能吗?谢谢。
如果您使用预定义名称 chpwd
定义了一个函数,它会在您的工作目录每次更改时执行。
zsh 手册页的“特殊功能”一章中描述了此行为