Skip to main content

Command Palette

Search for a command to run...

Environments Handbook

Updated
4 min read
N

Passionate software builder for a better web that enable, not replace people.

I switched contexts a lot when using technologies, either for work or personal projects, constantly remembering my existing config are overwhelming

Primarily for personal guide.


Essentials

  • I moved from WebStorm to use VSCode. As it’s getting too slow to handle medium-sized monorepo while waiting Windows stable build for Zed

  • Berkeley Mono Typeface

  • Bitwarden


Windows

Terminal

Enhanced cmd.exe by defining couple aliases, saved in %userprofile%\alias.cmd. Private alias.cmd is used

GNU utilities

Git for Windows is built on top of patched MSYS2 to make git works better in Windows pathing system, they also ship small subsets of familiar GNU utilities like ls, mkdir, etc built to work for Windows, to make this available via terminal, I exposed C:\Program Files\Git\usr\bin path which contains such executables.

Due to requirement of C family toolchains, for example gcc, MSYS2 is used to provides this toolchain in Windows. Default install C:\msys64.

Note: make sure to provide paths for MSYS2 binaries BEFORE Git for Windows to as Git for Windows to prevent common executable conflicts.

Other than that, it's generally preferred to use binaries from Git for Windows because of the likelihood of its included binaries has been patched to handle Windows pathing system better.

Caveat! Git for Windows and MSYS2 binaries paths might also contain executables that are natively included by Windows (example: ssh), using Windows built-in binaries are typically always preferred.

To make interop easier to deal with, make sure to expose these built-in binaries paths BEFORE MSYS2 and Git for Windows. Check interop correctness especially for gpg by GnuPG and ssh from built-in OpenSSH.

Tooling

  1. Rapid Environment Variables

  2. WizTree

Useful Fixes for Windows

  1. Missing UWP Icons due to Google Drive File Streams

MacOS

homebrew as main package manager

Terminal

This terminal section also applies for WSL2

MacOS has been shipping zsh by default, I avoid bloating my terminal with too many plugins, fast startup and staying lightweight are preferred.

Set zsh as default sh for WSL2: chsh -s $(which zsh)

Setup: install zdharma-continuum/zinit and configure

# Remove defualt ~/.zshrc that might be created during your first `zsh` run
# Add to ~/.zshrc after installing zdharma-continuum/zinit
# After the `Zinit` autoload block

zinit for \
    light-mode \
  zsh-users/zsh-autosuggestions \
    light-mode \
  zdharma-continuum/fast-syntax-highlighting \
  zdharma-continuum/history-search-multi-word \
    light-mode \
    pick"async.zsh" \
    src"pure.zsh" \
  sindresorhus/pure

In WSL2, syntax-highlight have performance issues due the inclusion of Windows paths by default. To improve performance, excluding Windows paths can be done by following this. But following the guide might also remove desired binaries from system path, e.g code for VSCode. It can be added back by creating function that act as alias that handle arguments passing.

# .zshrc
code() {
    /mnt/c/Program\ Files/Microsoft\ VS\ Code/bin/code "$@"
}

Language

Java

  • Adoptium JDK 21 via Homebrew for MacOS, directly on Windows

Python

  • Via uv

  • You generally don’t want to replace system python. Use virtualenv instead.

Go (Golang)

  • Direct install

Javascript/Node.js

MSYS2 for C Developement (Windows)

  • Install MSYS2

  • For Clang/LLVM toolchain (recommended)

    • pacman -S mingw-w64-ucrt-x86_64-clang
  • For GCC

    • pacman -S mingw-w64-ucrt-x86_64-gcc
  • Recommended to just use UCRT - Why UCRT?

  • MSYS2 Environments

Notes about MSYS2’s common GNU binaries - above.


Git

Use Git for Windows then expose git binaries path

Use Git from Homebrew for MacOS.

Commit Signing

  1. Enable GPG signing globally git config --global commit.gpgsign true.

  2. By default git will use gpg command by default to perform signing.

  3. Then you need to tell which GPG key to use for signing.

Windows-only note

By installing GnuPG (GPG) individually, you can use gpg command on Windows. But it's easier to install it via GPG4Win which also includes Kleopatra (make sure to tick it during installation) that provide interface for GPG keys & settings management e.g passphrase TTL.

When freshly installing GPG4Win, make sure to also follow Start The Agent on Startup guide right after

Associating GPG key with email on Git provider

To make sure git provider recognize signed commit properly, they need to associate an email with certain GPG key, this should be done once.

Use Windows built-in OpenSSH client for Git for Windows

With Windows including ssh-agent and OpenSSH client by default, this provide a lightweight and solid ssh baseline setup, just make sure to config Git to use it for its ssh command

Configure WSL to use Windows Git Credential Manager