Skip to content

Instantly share code, notes, and snippets.

@Francesco149
Last active November 18, 2021 19:49
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 Francesco149/1d84c2facb01c480d6b6462cf6172678 to your computer and use it in GitHub Desktop.
Save Francesco149/1d84c2facb01c480d6b6462cf6172678 to your computer and use it in GitHub Desktop.

if you ever find yourself having to code on windows, here's some sane tooling to get a smooth experience

keyboard repeat rate

windows doesn't allow you to set the keyboard repeat rate nearly high enough, so we have to use keyrate

to set a fast repeat rate at boot:

  • put keyrate.exe in C:
  • win+r -> shell:startup
  • create a .bat file
@echo off
C:\keyrate.exe 200 1

run it manually if you don't want to reboot

terminal emulator

the windows terminal and the legacy terminal are both ridiculously slow. we are going to use alacritty.

I also don't like using powershell or cmd so we are going to configure it to use bash.

paste the following and save:

shell:
  program: C:\msys64\usr\bin\bash.exe
  args:
  - --login

font:
     size: 14
     normal:
          family: JetBrains Mono

conclusion

now you can run alacritty and it should start within the msys2 environment

from here you can also call windows software (for example: start explorer.exe) and put that in scripts as needed

you can access windows files from directories like /c/Users/

it's up to you to install your favorite editor and configure bash to your liking

using tcc

git clone https://github.com/Kochise/tinycc_win32
cd tinycc_win32/win32
./make-tcc.bat
echo 'PATH="~/tinycc_win32/win32:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

to test the compiler, create this example:

#include <windows.h>

int WinMain() {
  MessageBoxA(0, "hello", "hi", MB_OK);
}

compile and test:

tcc ./hello.c
./hello.exe

using msvc compiler from alacritty + msys2 (absolutely proprietary)

create a gen-vcvars.bat file with the following (adjust visual studio path if incorrect)

@echo off
REM credits: https://gist.github.com/vvuk/01dc8a12678d1beffaa1e26549d03b02

set OLDPATH=%PATH%
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
SET "PATH=%CD%;%PATH%"

echo #!/bin/sh > vcvars.sh
echo export INCLUDE='%INCLUDE%' >> vcvars.sh
echo export LIB='%LIB%' >> vcvars.sh
echo export LIBPATH='%LIBPATH%' >> vcvars.sh

call set "NEWPATH=%%PATH:%OLDPATH%=%%"
set "NEWPATH=%NEWPATH:C:=/c%"
set "NEWPATH=%NEWPATH:\=/%"
set "NEWPATH=%NEWPATH:;=:%"

echo export PATH="%NEWPATH%:$PATH" >> vcvars.sh

this will generate a vcvars.sh that you can chmod and source:

./gen-vcvars.bat
chmod +x vcvars.sh
source ./vcvars.sh

now you should be able to run cl to compile stuff using msvc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment