[LINUX] How to launch Explorer from WSL

Introduction

I wanted to start Explorer from the command line like Git Bash inWSL (Windows Subsystem for Linux), so I tried to find out how to execute it.

The execution environment is as follows.

What I wanted to do

Git Bash allows you to run Explorer using the start command at the command prompt.

$ start explorer [Directory path]

In the same way, check with WSL to see if you can run Explorer from the command line.

result

As a result, WSL was able to run Explorer with the following command.

$ explorer.exe [Directory path]

Why you can execute files on the Windows side

I checked the contents of the environment variable PATH on the WSL side using the ʻenv command`.

$ echo $PATH | sed s/:/\\n/g | grep -Ei "/mnt/c/windows"
/mnt/c/Windows/system32
/mnt/c/Windows
/mnt/c/Windows/System32/Wbem
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/
/mnt/c/WINDOWS/system32
/mnt/c/WINDOWS
/mnt/c/WINDOWS/System32/Wbem
/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/
/mnt/c/WINDOWS/System32/OpenSSH/
/mnt/c/WINDOWS/system32
/mnt/c/WINDOWS
/mnt/c/WINDOWS/System32/Wbem
/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/
/mnt/c/WINDOWS/System32/OpenSSH/

Apparently, WSL reflects the environment variables on the Windows side by default, so it seems that you can specify an executable file such as a standard Windows command.

Execute the command without specifying .exe

I understand how to execute it, but since it is a hassle to specify .exe each time and execute it, register an alias.

Aliase registration

Register the alias in the bash configuration file .bashrc and set it so that the command can be executed without .exe.

$ vim ~/.bashrc

The edit screen of vim will be opened, so add the contents to .bashrc as follows.

alias [Command name]='[Executable file name]'

I set it as follows.

# aliases
alias explorer='explorer.exe'

After editing, use the source command to reload .bashrc to reflect the alias.

$ source ~/.bashrc

After executing the source command, check if the command can be executed without .exe.

$ explorer .

I think you can now run it without .exe. By the way, you can check the list of set aliases with the ʻalias command`.

Recommended Posts

How to launch Explorer from WSL
Transition from WSL1 to WSL2
How to instantly launch Jupyter Notebook from the terminal
How to use SWIG from waf
How to launch AWS Batch from a python client app
How to access wikipedia from python
How to convert from .mgz to .nii.gz
How to easily convert format from Markdown
How to update Google Sheets from Python
How to utilize multi-core from multiple languages
How to access RDS from Lambda (python)
How to operate Linux from the console
How to create a repository from media
How to access the Datastore from the outside
Sum from 1 to 10
How to open a web browser from python
How to create a function object from a string
Study from Python Hour7: How to use classes
How to get results from id in Celery
How to call Cloud API from GCP Cloud Functions
How to operate Linux from the outside Procedure
How to handle Linux commands well from Python
How to extract coefficients from a fractional formula
How to measure line speed from the terminal
How to Git from GCP's Jupyter Lab to GSR
Learn how to inflate images from TensorFlow code
How to clone github remote repository from atom
How to use xml.etree.ElementTree
How to use Python-shell
[Python] How to remove duplicate values from the list
How to create an article from the command line
How to use tf.data
How to use virtualenv
How to "cache enabled" access to FPGA memory from Linux
Scraping 2 How to scrape
How to use Seaboan
How to use image-match
How to use shogun
How to install Python
How to use Pandas 2
How to use Keras ~ From simple model generation to CNN ~
How to scrape image data from flickr with python
How to read PyPI
Changes from Python 3.0 to Python 3.5
How to install pip
Changes from Python 2 to Python 3.0
Terraform configured to launch AWS Lambda from Amazon SQS
How to use numpy.vectorize
How to install archlinux
How to use pytest_report_header
How to restart gunicorn
How to install python
How to virtual host
How to debug selenium
How to use Azure Table storage from Django (PTVS)
How to use partial
How to use Bio.Phylo
How to read JSON
How to use SymPy
How to use x-means
How to use WikiExtractor.py