'How to launch a new WSL bash window from an existing WSL bash window
I am struggling to figure out how to launch a new "command prompt" window via a bash command in WSL. The goal is to launch a second prompt preferably already in bash.
I have already tried running cmd.exe
yet that just drops me to a standard windows command prompt cmd from with in the bash shell.
https://i.imgur.com/tIdRMvR.png
Running the bash.exe
or wsl.exe
commands just takes me to another bash shell from within that same bash shell.
https://i.imgur.com/OM1XTlG.png
I am using the Debian distribution for WSL though that should not matter.
I know you can make a new window from the standard command prompt by putting the start
command before the program. Yet I can not find the *nix equivalent or how to call a bash command from within WSL that does the same thing.
Solution 1:[1]
Solution 2:[2]
The only way you're going to launch a new window from WSL is if you use some sort of terminal emulator and launch it. There are a number of different options: wsltty, wsl-terminal, Conemu, and Cmder (which is based upon Conemu) all come to mind offhand. Wsltty is based upon mintty which is the default terminal emulator for Cygwin, which is what people used before WSL came long. I personally like Cmder, but I found set up to be painful. YMMV.
Solution 3:[3]
even better one if you want to open a certain distro
go to the explorer type shell:AppsFolder
find your distro make a shortcut to your desktop
and do this within your wsl
$ cmd.exe /c <absolute path of that shortcut>
eg:
$ cmd.exe /c "C:\Users\fake user which i just made up\Desktop\Ubuntu.lnk"
you can also copy the shortcut to somewhere and use the absolute path instead of only distro name you might need to use ""
enclosing the path
edit : if you find yourself having this error CMD.EXE was started with the above path as the current directory.UNC paths are not supported
i couldn't find any solution to that you can use this docs to cmd.exe params
Solution 4:[4]
There is no need to call cmd twice. I use this kind of thing:
cmd.exe /c start wsl.exe -d $WSL_DISTRO_NAME --user $LOGNAME -- ssh -p 23 -L 80:10.0.0.1:80 -L 443:10.0.0.1:443 username@remoteserver
this will open another wsl window for the same user and distribution of the caller window and start ssh session in it. The ssh session can be replaced with whatever you want to run in the new window ... if you want just the shell prompt omit everything after $LOGNAME
Solution 5:[5]
(Note you need to install Windows Terminal if you don't already have it in order for this solution to work).
So none of these answers really worked for me. Turns out the best solution for me was to use cmd.exe to open bash through windows terminal (wt.exe), ie:
cmd.exe /c "wt.exe" -p "Debian"
Use -p to indicate the profile name of your command-line app, or leave it to use the default.
You can use this to open in a new tab and to pass commands as well:
cmd.exe /c "wt.exe" -w 0 nt -p "Debian" python example.py
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | DanR |
Solution 2 | SeeJayBee |
Solution 3 | |
Solution 4 | louigi600 |
Solution 5 | Discant |