2

I'm on Windows 10 and trying to run a startup script (vcvars64.bat) to setup the MSVC compiler before using the Alacritty prompt. I have tried the -e switch with the command and also with the alacritty.yml shell: option, but both options open Alacritty, run the command, then exit.

How do I run a script on startup as the first command then continue into Alacritty?

Thanks, Matic

Matic Kukovec
  • 354
  • 2
  • 9

1 Answers1

3

What I ended up with is:

  1. Specify program: cmd.exe in Alacritty alacritty.yml:
    shell:
      program: cmd.exe
    
  2. Create a shortcut to Alacritty.exe and place it eg. in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\ (so that it shows up in Windows search).
  3. In properties for the shortcut, under target, specify:
    "C:\Program Files\Alacritty\alacritty.exe" --command "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat >/NUL" && bash.exe
    
    Modify Visual Studio path to whatever you have, and which varsall.bat you want to use.

The tricky part was how sensitive cmd.exe is regarding quotes. Eg., it does not work for me to specify an absolute path to which bash.exe to use, it would fail on the first whitespace in the path no matter how I tried to quote it. So make sure the correct bash.exe is first in your PATH (open plain cmd.exe and run where bash.exe to see order). Another solution is of course to create a shortcut to the bash.exe of your liking to a place without spaces in its path then specify it's absolute path (tested to work).

helmesjo
  • 625
  • 5
  • 17
  • I'm looking for something like this in macOS. Any idea? – ranemirusG Jan 28 '23 at 21:09
  • @ranemirusG For *nix systems it isn't as complicated (tools aren't spread around all over the place). In your terminal, just check with `which clang++`, and if it shows up you are good to go (assuming you're not cross-compiling for some exotic cpu). – helmesjo Feb 06 '23 at 21:04