Change directory depending on start directory zsh
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
Related videos on Youtube
Lira
Updated on September 18, 2022Comments
-
Lira over 1 year
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?
-
QuickishFM over 4 yearsYou could run a command at startup every time, that checks if
pwd
returns /mnt/c/WIndows/System32, and if so, then itcd
s 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.
-