I have WSL (Windows Subsystem for Linux) set up on my computer with Ubuntu.
When I want a Linux session, I hit Win+R
and type bash
because it's short and quick.
However, it always drops me into /mnt/c/Users/Michael
.
I want it to drop me into my Ubuntu home directory (~
) instead.
I've tried adding cd ~
to my .bash_profile, but then whenever I try to run bash
from the command line, it always takes me to ~
, instead of opening bash in the current directory.
I can get around this by running ubuntu
from the Run Dialog, but it takes longer and is harder to spell.
How can I get bash
to open ~
when run from the run dialog, and the current working directory when run from Command Prompt or PowerShell? Or, what are some good workarounds?
Best Answer
A simple kludge (workaround) would be to put
into your
.bash_profile
. That way, if you’re in your Windows home directory (C:\Users\Michael
) when you runbash
, it will go to your Ubuntu home directory. If you’re anywhere else, it will stay there.This is a kludge/workaround inasmuch as, if you manually go to
C:\Users\Michael
in Command Prompt or PowerShell,bash
will stillcd
to~
.