11

I just installed WSL2 with Ubuntu 20.04 on my Windows 10 machine and I also installed Alacritty terminal emulator for Windows. I'm wondering is there a way to make WSL to default into using Alacritty terminal over the default one? If so, any idea how to achieve it? Alacritty's github didn't say much about WSL (https://github.com/alacritty/alacritty).

Oluevaera
  • 113

5 Answers5

11

modify your alacritty.yml shell section as below:

# Shell
#
# You can set `shell.program` to the path of your favorite shell, e.g.
# `/bin/fish`. Entries in `shell.args` are passed unmodified as arguments to the
# shell.
#
# Default:
#   - (macOS) /bin/bash --login
#   - (Linux/BSD) user login shell
#   - (Windows) powershell
shell:
  program: ubuntu
#  args:
#    - --login
5

You can create a shortcut.

"C:\path\to\alacritty\alacritty.exe" --command ubuntu

enter image description here


enter image description here

patstuart
  • 151
4

Short answer, there's currently no way to change the default terminal that launches (WSL, PowerShell, CMD, etc.) to Alacritty.

Your best bet would be to create a small .ps1 or .cmd script that would launch Alacritty with WSL. You could then add that as a shortcut to the Start Menu for quick access. Pinning it to the Start or Task bar would also be a possibility.


More background:

When this question was originally asked, it had just recently become possible to set Windows Terminal (Preview) in Windows 10 build 21390 (Insider/Preview). You could select between the older Windows Console (which was the default) and the newer Windows Terminal.

Ultimately, the Insider builds of Windows 10 from that time became Windows 11. Most new functionality was not rolled back to Windows 10 21H2, including this feature.

It is possible for other terminal applications to register themselves as replacement terminals as well, but it is not easy. To quote from Alacritty issue #6036, which is tracking this feature request:

If this takes what Christian Parpart described in the contour issue, I doubt this will ever be merged into Alacritty. But if there's some more minimal solutions, feel free to send a patch.

It requires creation and registration of a COM server for the terminal application, which might be a bit of a lost art (exaggeration, but it's definitely not something that is commonly done nowadays).

That said, Windows Terminal is open-sourced, so it's possible to examine exactly how it is implemented there. The relevant code is, I believe in Windows Terminal PR #7489.

NotTheDr01ds
  • 28,025
4

At least for me the answer is to add following snippet to alacritty.yml

shell:
  program: wsl

or the following to alacritty.toml file (if you've already migrated):

[shell]
  program = "wsl"

Which is different from another answer where it says ubuntufor the program.

Philipp
  • 153
2

Similar to Pat Stuart's solution but chooses distribution, user, and home location within WSL:

"C:\Program Files\Alacritty\alacritty.exe" --command "wsl -d Ubuntu-24.04 -u d --cd /home/d"