根据 zsh 的启动目录更改目录

Lir*_*ira 4 windows linux zsh ubuntu windows-subsystem-for-linux

我使用新的 Windows 10 终端,其中包含 WSL ubuntu 和 zsh (oh-my-zsh) shell 作为内部标准终端。配置上下文菜单(右键单击)具有“在此处打开终端”选项。它将在我调用它的目录中使用 Ubuntu 和 zsh shell 打开新终端。它工作得很好,但现在当我通过开始菜单打开终端时,开始目录是/mnt/c/Windows/System32.

我希望在终端启动时目录更改为主目录(如果它以/mnt/c/Windows/System32.

我怎样才能做到这一点?我如何知道 zsh 将在哪个目录中启动?

Lir*_*ira 6

感谢 QuickishFM 我找到了解决方案。我在其他堆栈帖子中看到,if [[ "${pwd}" == "/mnt/c/Windows/System32" ]] ... fi但这确实有效。经过一番研究我找到了解决方案。

if [[ $(pwd) == /mnt/c/Windows/System32  ]]
then
    cd ~
fi
Run Code Online (Sandbox Code Playgroud)

谢谢