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.
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.
As a result, WSL
was able to run Explorer with the following command.
$ explorer.exe [Directory path]
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.
I understand how to execute it, but since it is a hassle to specify .exe
each time and execute it, register an alias.
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