When I open the WSL by clicking on its icon I need it to be opened in a certain directory (of course one that is more useful than System32
), so I add a cd destination
in my .bashrc
. But then the "Open Linux Shell Here" option (available when you hold the Shift key on keyboard and right-click on any folder is also being redirected to that destination, which is undesirable. Is there a way I can detect this case in my .bashrc
script and let it behave as it should?
In short, I need to know when the shell has been opened by the option in Shift+Right Click inside a folder, so that I can avoid changing the working directory to another one.
I'm using WSL-Ubuntu 18.04 LTS
and GNU bash, version 4.4.19(1)-release (x86_64-pc-linux-gnu)
.
Best Answer
I would change the
~/.bashrc
enhancement to something like this:Where
$SystemDir
is your System32 directory. Always remember how\
and/
differ between Windows and Linux paths:Suggests using:
That said in your instance you could probably hard-code the path.