Skip to content

Instantly share code, notes, and snippets.

@ha7ilm
Last active May 23, 2022 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ha7ilm/e3b982381a862470a6c26d68e7d64345 to your computer and use it in GitHub Desktop.
Save ha7ilm/e3b982381a862470a6c26d68e7d64345 to your computer and use it in GitHub Desktop.
Execute command inside Windows Terminal and WSL

Execute command inside Windows Terminal and WSL

I do it like this:

wt -p "Ubuntu" wsl zsh -c "command_to_execute"
  • Ubuntu is the name of the profile
  • zsh is my shell
  • command_to_execute is what I would type into zsh

For example, to open vim at a given path:

wt -p "Ubuntu" wsl zsh -c "vim $(wslpath 'C:\myfile.txt')"  
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment