The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 483     Votes:  3     ✅ Solution
Tags: bashrc   windows-subsystem-for-linux  
Link: 🔍 See Original Answer on Ask Ubuntu ⧉ 🔗

URL: https://askubuntu.com/q/1162728
Title: WSL: Is there a conditional to detect "Open Linux Shell Here" case?
ID: /2019/08/01/WSL_-Is-there-a-conditional-to-detect-_Open-Linux-Shell-Here_-case_
Created: August 1, 2019    Edited:  August 2, 2019
Upload: September 15, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


I would change the ~/.bashrc enhancement to something like this:

CurrDir="$(pwd)"
if [[ "$CurrDir" == "$SystemDir" ]]
then
    cd /path/to/sensible-dir-name
Fi

Where $SystemDir is your System32 directory. Always remember how \ and / differ between Windows and Linux paths:

Suggests using:

sed -e 's#^J:##' -e 's#\\#/#g'

That said in your instance you could probably hard-code the path.

⇧ Which LTS version is supported? 18.04.1 or 18.04.2? both? How can you tell the version of Ubuntu on a system in a .sh (bash) script?  ⇩