From some point, suddenly (I guess after an Ubuntu update?), it starts in the root directory when I open a new terminal.
I want to start from my home directory as before.
The below is my shell script(I removed all the comments).
I am running Ubuntu on WSL2 on Windows 10
export ZSH="/home/myubuntu/.oh-my-zsh"
ZSH_THEME="bira"
DISABLE_LS_COLORS="true"
plugins=(git)
source $ZSH/oh-my-zsh.sh
alias tre='tree -a -C -I '\''node_modules|.git'\'' --dirsfirst'
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
#cd workspace
if [ "$PWD" = "$HOME" ]; then cd workspace; fi
# added by travis gem
[ ! -s /home/myubuntu/.travis/travis.sh ] || source /home/myubuntu/.travis/travis.sh
This is Ubuntu info
╰─$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal
Anyone knows how to fix this?
>Solution :
I see in the comments that you got this working, but there are several ways to do this under Windows Terminal:
-
Under Windows 10 21H2 and Windows 11, you can specify a Linux directory instead of the Windows path for
startingDirectory. So now/home/taeilwill work (assuming you are upgraded). See this answer on Stack Overflow for details and a link to the Microsoft Doc. -
Under previous versions, you do need to use the Windows format
\\wsl$\path (quoted) as noted in the comments. In your case, it looks like this would be\\\\wsl$\\Ubuntu\\home\\taeil -
Personally, for using your Linux home directory as a starting point, I recommend this technique (my answer in that same Stack Overflow question). Just start wsl with
wsl ~to start in your home directory. -
Also, with Windows 10 21H2 and Windows 11,
wsl --cd ~works.