ekinakkaya / iswsl

Small script that checks if you are using WSL by looking at runtime system information.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iswsl

Small bash script that checks if you are using WSL (Windows Subsystem for Linux) by looking at runtime system information (proc files).

Install

Recommended to execute commands one at a time

cd
git clone https://github.com/ekinakkaya/iswsl.git
cd iswsl

sudo mv ./iswsl /usr/local/bin
sudo chmod 755 iswsl
cd .. && rm -r iswsl

or (recommended)

curl --silent https://raw.githubusercontent.com/ekinakkaya/iswsl/main/iswsl > ~/iswsl-script
sudo mv ~/iswsl-script /usr/local/bin/iswsl
sudo chmod 755 /usr/local/bin/iswsl

or one liner function adder to your .bashrc file

echo "iswsl () {" > iswsl-bashrc && curl --silent https://raw.githubusercontent.com/ekinakkaya/iswsl/main/iswsl-bashrc | tail -n +3 >> iswsl-bashrc && echo "}" >> iswsl-bashrc && cat iswsl-bashrc >> ~/.bashrc

Example use case

if iswsl; then
    # do some wsl tasks
    echo wow, i'm in WSL
    
    # get the windows username
    cmd.exe /c "echo %USERNAME%"
else
    # do non-wsl tasks
    echo not in wsl
fi

About

Small script that checks if you are using WSL by looking at runtime system information.


Languages

Language:Shell 100.0%