Skip to content

Add Windows + Git Bash support via winget manifests, zsh handoff, and standalone bootstrap script#2

Draft
Copilot wants to merge 6 commits intomainfrom
copilot/add-windows-git-bash-support
Draft

Add Windows + Git Bash support via winget manifests, zsh handoff, and standalone bootstrap script#2
Copilot wants to merge 6 commits intomainfrom
copilot/add-windows-git-bash-support

Conversation

Copy link

Copilot AI commented Jan 2, 2026

Adds Windows bootstrap support that reuses the existing zsh configuration structure. Git Bash auto-launches zsh on Windows; all existing macOS/Linux behavior is preserved.

Implementation

Package manifests (manifests/windows/)

  • common.txt / windows-only.txt - winget package IDs (one per line, comments allowed)
  • Per-hostname manifests supported: {{ hostname }}.txt

Windows package installer (run_onchange_install-windows.ps1.tmpl)

  • Merges all manifests, installs via winget install --id <ID> --exact --silent
  • Idempotent: handles already-installed packages gracefully
  • Includes manifest hashes in template for run_onchange detection

Git Bash zsh setup (run_onchange_10-setup-gitbash-zsh.sh.tmpl)

  • Installs zsh via pacman -S --noconfirm zsh
  • Numbered 10 to run before other zsh-dependent scripts

Zsh auto-launch (dot_bashrc.tmpl)

  • Detects interactive terminal and launches zsh if available
  • Loop prevention via $ZSH_VERSION check

Windows environment (dot_config/shell/env.windows.zsh)

  • Windows-specific PATH (PowerShell, pnpm locations differ)
  • Sourced by env.zsh only when $OSTYPE matches msys|cygwin|mingw

Standalone Windows bootstrap script (install.ps1)

  • PowerShell script that can be downloaded and run independently
  • Installs winget (if needed)
  • Installs Git for Windows (includes Git Bash)
  • Installs chezmoi
  • Applies dotfiles configuration
  • Handles custom installation paths automatically

Usage:

iwr -useb https://raw.githubusercontent.com/mkhnsn/dotfiles/main/install.ps1 | iex

Modified files

dot_config/shell/env.zsh - Added 9 lines at top for Windows/MSYS detection:

# Check OSTYPE first (no subprocess), fallback to uname only if OSTYPE is unclear
if [[ "$OSTYPE" =~ ^(msys|cygwin|mingw) ]]; then
  [[ -r "$HOME/.config/shell/env.windows.zsh" ]] && source "$HOME/.config/shell/env.windows.zsh"
elif [[ -z "$OSTYPE" && "$(uname -s 2>/dev/null)" =~ ^(MINGW|MSYS) ]]; then
  [[ -r "$HOME/.config/shell/env.windows.zsh" ]] && source "$HOME/.config/shell/env.windows.zsh"
fi

README.md - Added Windows installation instructions and updated repository structure documentation.

All other files (.zshrc, existing run_onchange_* scripts, aliases.zsh, functions.zsh) are untouched.

Flow

Windows (via standalone script): Run install.ps1 → installs Git for Windows, chezmoi → runs chezmoi apply → winget installs packages → zsh installed in Git Bash → Git Bash auto-launches zsh

Windows (via chezmoi): chezmoi apply → winget installs packages → zsh installed in Git Bash → .bashrc auto-launches zsh → .zshrc loads env.zshenv.zsh sources env.windows.zsh

macOS/Linux: Windows templates don't render (conditional), OSTYPE check fails, no behavior change

Original prompt

Task: Add Windows + Git Bash bootstrap support (additive, reuse existing zsh structure)

Hard constraints

  • Do not change existing macOS/Linux behavior
  • Do not refactor .zshrc, env.zsh, or existing run_onchange_* scripts
  • Only add Windows support in a way that plugs into the current structure

Current shell layout (assume this is correct)

  • .zshrc = minimal loader
  • env.zsh = bulk of config
  • Additional run_onchange_* scripts exist and should remain intact

Windows work should reuse this setup, not duplicate it.


Goals

  1. On Windows, use winget to install common apps + Windows-specific tools.

  2. Ensure Git Bash launches into zsh automatically.

  3. Ensure your existing zsh flow loads the same way:

    • .zshrc loads env.zsh
    • existing run_onchange_* scripts still run as designed
  4. Add minimal Windows conditionals only where necessary (paths, tool availability).


New manifests (Windows only)

Add:

manifests/windows/common.txt
manifests/windows/windows-only.txt
# optional per-machine:
manifests/windows/{{ .chezmoi.hostname }}.txt

These files contain winget package IDs, one per line, comments allowed.


New chezmoi script (Windows-only)

Add:

run_onchange_install-windows.ps1.tmpl

Behavior:

  • Run only when {{ if eq .chezmoi.os "windows" }}

  • Read + merge these lists if present:

    • manifests/windows/common.txt
    • manifests/windows/windows-only.txt
    • manifests/windows/{{ .chezmoi.hostname }}.txt
  • For each ID, run:

    • winget install --id <ID> --exact --silent --accept-package-agreements --accept-source-agreements
  • Must be idempotent: don’t fail if already installed.


Git Bash → zsh handoff (Windows)

Add a Git Bash config snippet (via chezmoi-managed file) that:

  • Installs zsh in Git Bash using pacman if missing:

    • pacman -S --noconfirm zsh
  • Auto-launches zsh when opening Git Bash interactively by adding to ~/.bashrc:

    if [ -t 1 ] && command -v zsh >/dev/null; then
      exec zsh
    fi
  • Do not alter .zshrc logic beyond what’s strictly necessary.


Windows-specific environment handling (minimal)

Add only if needed:

  • A small conditional in env.zsh (or a separate env.windows.zsh sourced by env.zsh) to handle:

    • path differences in Git Bash (/c/Users/...)
    • optional tools not present on Windows
  • Prefer a separate file (e.g. env.windows.zsh) that env.zsh sources when running on Windows/MSYS to avoid touching existing logic.

Detection suggestion (Git Bash / MSYS):

  • $OSTYPE contains msys or cygwin, or uname contains MINGW

Non-goals

  • No WSL setup
  • No changes to macOS/Linux install scripts
  • No replacement of your existing env/zsh structure
  • No deep PowerShell profile customization

Acceptance criteria

  • chezmoi apply on Windows:

    • Installs packages via winget
    • Git Bash opens and immediately runs zsh
    • .zshrc loads env.zsh as it does on macOS/Linux
    • Existing on_change scripts still behave normally
  • chezmoi apply on macOS/Linux produces no changes beyond any existing behavior (i.e., no regressions)


Tiny extra suggestion (optional but smart):
Have the Windows winget script and the Git Bash zsh install be separate run_onchange_ scripts so you can debug them independently.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits January 2, 2026 19:05
Co-authored-by: mkhnsn <10660565+mkhnsn@users.noreply.github.com>
Co-authored-by: mkhnsn <10660565+mkhnsn@users.noreply.github.com>
Co-authored-by: mkhnsn <10660565+mkhnsn@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Windows and Git Bash bootstrap support Add Windows + Git Bash support via winget manifests and zsh handoff Jan 2, 2026
Copilot AI requested a review from mkhnsn January 2, 2026 19:13
@mkhnsn
Copy link
Owner

mkhnsn commented Jan 6, 2026

@copilot can we add a windows version of a bootstrap script also? something that can be downloaded standalone, and run as a shell script in normal cmd to get everything set up, including installing git bash, etc.

Co-authored-by: mkhnsn <10660565+mkhnsn@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 6, 2026

@copilot can we add a windows version of a bootstrap script also? something that can be downloaded standalone, and run as a shell script in normal cmd to get everything set up, including installing gi...

Added install.ps1 - a standalone Windows bootstrap script that can be downloaded and run in PowerShell.

Usage:

iwr -useb https://raw.githubusercontent.com/mkhnsn/dotfiles/main/install.ps1 | iex

The script will:

  • Install winget (if needed)
  • Install Git for Windows (includes Git Bash)
  • Install chezmoi
  • Apply your dotfiles

After running, open Git Bash from the Start Menu and it will automatically launch zsh with your configuration.

Commit: e5b14c5

Co-authored-by: mkhnsn <10660565+mkhnsn@users.noreply.github.com>
Copilot AI changed the title Add Windows + Git Bash support via winget manifests and zsh handoff Add Windows + Git Bash support via winget manifests, zsh handoff, and standalone bootstrap script Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments