- Add 'theme status' command to show current theme status across platforms - Add 'theme toggle' command to switch between light and dark themes - Improve toggle logic to read current theme from platform-specific sources - Update documentation to include new commands - Maintain backward compatibility with existing theme light/dark commands
3 KiB
3 KiB
Unified Theme Switching
Unified theme switching that works across platforms (WSL and macOS) for Neovim, Alacritty, and Windows Terminal.
This solution uses a single theme command that detects the platform and switches themes appropriately.
How It Works
- The
themecommand detects the platform (WSL vs macOS) - On WSL: Updates Neovim, Windows Terminal, and Windows system theme
- On macOS: Updates Neovim and Alacritty themes via Nix configuration
- Uses the same
nvim_color_schemefile for Neovim on both platforms
Setup
-
The configuration is already set up! The
themecommand is available as a fish alias. -
To switch themes, use the unified command:
theme light # Switch to light theme theme dark # Switch to dark theme theme toggle # Toggle between light and dark themes theme status # Show current theme status
Usage
Unified Theme Command
# Switch to light theme (works on WSL and macOS)
theme light
# Switch to dark theme (works on WSL and macOS)
theme dark
# Toggle between light and dark themes
theme toggle
# Show current theme status
theme status
What Gets Updated
On WSL:
- Neovim theme (via
~/.local/share/nvim_color_scheme) - Windows Terminal settings
- Windows system theme
- Windows sound scheme
On macOS:
- Neovim theme (via
~/.local/share/nvim_color_scheme) - Alacritty theme (via Nix configuration)
Manual Configuration (macOS only)
You can also manually edit nixos/home/danny/home.nix and change:
isLightTheme = true; # for light theme
isLightTheme = false; # for dark theme
Then run: cd nixos && sudo darwin-rebuild switch --flake .#Daniel-Macbook-Air
Files
scripts/theme.sh- Main unified theme switching scriptscripts/switch-alacritty-theme.sh- Alacritty-specific theme switching (used by theme.sh)scripts/detect-system-theme.sh- Detects current macOS system theme (for reference)nixos/fish.nix- Contains thethemefish aliasnixos/home/danny/home.nix- Contains the conditional Alacritty configurationbashscripts/wsl_theme.sh- Legacy WSL script (replaced by theme.sh)
Theme Colors
Catppuccin Latte (Light)
- Background:
#eff1f5(base) - Foreground:
#4c4f69(text) - Accent colors optimized for light backgrounds
Catppuccin Mocha (Dark)
- Background:
#1e1e2e(base) - Foreground:
#cdd6f4(text) - Accent colors optimized for dark backgrounds
Integration with NixOS
The solution uses Nix's conditional configuration in home.nix:
colors = let
isLightTheme = true; # Change this to switch themes
lightColors = { /* Catppuccin Latte colors */ };
darkColors = { /* Catppuccin Mocha colors */ };
in if isLightTheme then lightColors else darkColors;
This approach:
- ✅ Works with Spotlight/Applications folder launches
- ✅ No complex file reading or external dependencies
- ✅ Integrates cleanly with NixOS configuration
- ✅ Simple and reliable - just change a boolean and rebuild
- ✅ Easy to understand and maintain