4

I am using the new Windows 10 terminal with the WSL ubuntu and zsh (oh-my-zsh) shell as the standard terminal inside. It is configured that the context menu (right-click) has the option "open terminal here". It will open the new terminal with the Ubuntu and zsh shell in the directory I called it from. It works perfectly but now when I open the terminal via the start menu the start directory is /mnt/c/Windows/System32.

I want that on start-up of the terminal the directory changes to the home directory if it would start in /mnt/c/Windows/System32.

How can I do that? How do I know in which directory zsh will start?

1
  • 1
    You could run a command at startup every time, that checks if pwd returns /mnt/c/WIndows/System32, and if so, then it cds into ~. Perhaps theres a way to do this in the zsh configuration file like you can do for .bashrc, for example. I only use Bash for now so I'm unsure how to implement it straight up - but this should get you on the right track.
    – QuickishFM
    Commented Dec 25, 2019 at 22:07

1 Answer 1

6

Thanks to QuickishFM I found the solution. I saw in an other stack post if [[ "${pwd}" == "/mnt/c/Windows/System32" ]] ... fi but that did work. After some research i found the solution.

if [[ $(pwd) == /mnt/c/Windows/System32  ]]
then
    cd ~
fi

Thanks

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .