Skip to content
Advertisement

Open tabs in Windows Terminal w/ Ubuntu WSL & Zsh

I’m writing a script to run on UBUNTU WSL in Windows. I use zsh as my shell, but bash could work too here.

I’d like that bash script to use wt.exe (Windows Terminal) to open some new tabs.

Here’s what I have so far:

JavaScript

You’ll need Windows 10 w/ Ubuntu WSL and Windows Terminal for that to work.

This bash script opens a bunch of tabs.

  • Tabs that ls immediately exit.
  • Tabs that error stick around.

enter image description here I’d like to automate:

  • opening several tabs in different folders:
  • run a command (yarn dev)
  • cancel that command (ctrl-c) and have the terminal interactive instead of exit.

I got this to work on previous version of these tools, but they changed.

What’s the new way?

Advertisement

Answer

zsh ls does not make sense. In general,

JavaScript

asks zsh to interpret some_file as a text file containing a zsh script. To invoke the external command ls, you would at least have to write

JavaScript

In your case, it makes perhaps (depending on how you configured zsh) sense to run it as login shell. The invocation would be then something like

JavaScript

Of course the zsh exits after that immediately, because you don’t open an interactive shell. To achieve this, you could overlay your non-interactive zsh with an interactive zsh process after the ls has been performed:

JavaScript
Advertisement