Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 763
Melon Bread Avatar asked Apr 25 '19 05:04

Melon Bread


People also ask

How do I open a new window in WSL?

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.

How do I create a new window in bash?

Press alt + d and type get-bash and you are good to go.

How do I start bash in WSL?

To start using WSL, open up a PowerShell terminal and type wsl . If you've set up WSL correctly, you'll enter a bash terminal running on the WSL distro of choice. From here, you can run any Linux commands you wish.

How do I open a terminal bash window?

To access the shell, simply type 'bash' in the Windows command prompt, and everything is good to go.


2 Answers

This works from a bash prompt in WSL.

cmd.exe /c start cmd.exe /c wsl.exe

(Solution found here)

like image 68
DanR Avatar answered Nov 06 '22 12:11

DanR


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

like image 36
louigi600 Avatar answered Nov 06 '22 10:11

louigi600