From 36f0e7d86357cf60f94c31375da16042535659db Mon Sep 17 00:00:00 2001 From: Harivansh Rathi Date: Wed, 8 Apr 2026 13:54:00 -0400 Subject: [PATCH] feat: lazygit theme --- config/lazygit/config.yml | 20 -------------- home/lazygit.nix | 11 ++++++-- lib/theme.nix | 56 +++++++++++++++++++++++++++++++++++++++ scripts/default.nix | 8 ++++++ scripts/theme.sh | 12 ++++++++- 5 files changed, 84 insertions(+), 23 deletions(-) diff --git a/config/lazygit/config.yml b/config/lazygit/config.yml index cd7c1c7..62098d5 100644 --- a/config/lazygit/config.yml +++ b/config/lazygit/config.yml @@ -10,23 +10,3 @@ gui: showRandomTip: false splitDiff: auto border: rounded - theme: - activeBorderColor: - - "#b8bb26" - - bold - inactiveBorderColor: - - "#504945" - selectedLineBgColor: - - "#3c3836" - optionsTextColor: - - "#fabd2f" - selectedRangeBgColor: - - "#504945" - cherryPickedCommitBgColor: - - "#689d6a" - cherryPickedCommitFgColor: - - "#282828" - unstagedChangesColor: - - "#fb4934" - defaultFgColor: - - "#ebdbb2" diff --git a/home/lazygit.nix b/home/lazygit.nix index e9459ef..09afb6d 100644 --- a/home/lazygit.nix +++ b/home/lazygit.nix @@ -1,12 +1,19 @@ { lib, hostConfig, + theme, ... }: +let + baseConfig = builtins.readFile ../config/lazygit/config.yml; + mkFullConfig = mode: baseConfig + theme.renderLazygit mode; +in { - xdg.configFile."lazygit/config.yml".source = ../config/lazygit/config.yml; + xdg.configFile."lazygit/config-dark.yml".text = mkFullConfig "dark"; + xdg.configFile."lazygit/config-light.yml".text = mkFullConfig "light"; home.file = lib.mkIf hostConfig.isDarwin { - "Library/Application Support/lazygit/config.yml".source = ../config/lazygit/config.yml; + "Library/Application Support/lazygit/config-dark.yml".text = mkFullConfig "dark"; + "Library/Application Support/lazygit/config-light.yml".text = mkFullConfig "light"; }; } diff --git a/lib/theme.nix b/lib/theme.nix index f30e006..e869c49 100644 --- a/lib/theme.nix +++ b/lib/theme.nix @@ -26,6 +26,8 @@ let ghosttyCurrentFile = "${config.xdg.configHome}/ghostty/themes/cozybox-current"; tmuxDir = "${config.xdg.configHome}/tmux/theme"; tmuxCurrentFile = "${config.xdg.configHome}/tmux/theme/current.conf"; + lazygitDir = "${config.xdg.configHome}/lazygit"; + lazygitCurrentFile = "${config.xdg.configHome}/lazygit/config.yml"; }; themes = { @@ -191,6 +193,59 @@ let zstyle ':prompt:pure:user:root' color '${c.error}' ''; + renderLazygit = + mode: + let + c = + if mode == "light" then + { + activeBorder = "#427b58"; + inactiveBorder = "#c3c7c9"; + selectedLineBg = "#e1e1e1"; + optionsText = "#b57614"; + selectedRangeBg = "#c3c7c9"; + cherryPickedBg = "#427b58"; + cherryPickedFg = "#e7e7e7"; + unstaged = "#c5524a"; + defaultFg = "#3c3836"; + } + else + { + activeBorder = "#b8bb26"; + inactiveBorder = "#504945"; + selectedLineBg = "#3c3836"; + optionsText = "#fabd2f"; + selectedRangeBg = "#504945"; + cherryPickedBg = "#689d6a"; + cherryPickedFg = "#282828"; + unstaged = "#fb4934"; + defaultFg = "#ebdbb2"; + }; + in + '' + gui: + theme: + activeBorderColor: + - "${c.activeBorder}" + - bold + inactiveBorderColor: + - "${c.inactiveBorder}" + selectedLineBgColor: + - "${c.selectedLineBg}" + optionsTextColor: + - "${c.optionsText}" + selectedRangeBgColor: + - "${c.selectedRangeBg}" + cherryPickedCommitBgColor: + - "${c.cherryPickedBg}" + cherryPickedCommitFgColor: + - "${c.cherryPickedFg}" + unstagedChangesColor: + - "${c.unstaged}" + defaultFgColor: + - "${c.defaultFg}" + ''; + batTheme = mode: if mode == "light" then "gruvbox-light" else "gruvbox-dark"; deltaTheme = mode: if mode == "light" then "gruvbox-light" else "gruvbox-dark"; @@ -263,6 +318,7 @@ in paths renderFzf renderGhostty + renderLazygit renderPurePrompt renderTmux renderZshHighlights diff --git a/scripts/default.nix b/scripts/default.nix index 2e7cd9f..7362df5 100644 --- a/scripts/default.nix +++ b/scripts/default.nix @@ -102,6 +102,14 @@ let "@TMUX_DARK_FILE@" = "${tmuxConfigs.dark}"; "@TMUX_LIGHT_FILE@" = "${tmuxConfigs.light}"; "@TMUX_CONFIG@" = "${config.xdg.configHome}/tmux/tmux.conf"; + "@LAZYGIT_DIR@" = theme.paths.lazygitDir; + "@LAZYGIT_CURRENT_FILE@" = theme.paths.lazygitCurrentFile; + "@LAZYGIT_DARK_FILE@" = "${theme.paths.lazygitDir}/config-dark.yml"; + "@LAZYGIT_LIGHT_FILE@" = "${theme.paths.lazygitDir}/config-light.yml"; + "@LAZYGIT_DARWIN_DIR@" = "${config.home.homeDirectory}/Library/Application Support/lazygit"; + "@LAZYGIT_DARWIN_FILE@" = "${config.home.homeDirectory}/Library/Application Support/lazygit/config.yml"; + "@LAZYGIT_DARWIN_DARK_FILE@" = "${config.home.homeDirectory}/Library/Application Support/lazygit/config-dark.yml"; + "@LAZYGIT_DARWIN_LIGHT_FILE@" = "${config.home.homeDirectory}/Library/Application Support/lazygit/config-light.yml"; "@WALLPAPER_DARK_FILE@" = "${theme.wallpapers.dark}"; "@WALLPAPER_LIGHT_FILE@" = "${theme.wallpapers.light}"; }; diff --git a/scripts/theme.sh b/scripts/theme.sh index f3a6908..7a60ab3 100644 --- a/scripts/theme.sh +++ b/scripts/theme.sh @@ -26,6 +26,7 @@ link_mode_assets() { fzf_target="@FZF_DARK_FILE@" ghostty_target="@GHOSTTY_DARK_FILE@" tmux_target="@TMUX_DARK_FILE@" + lazygit_target="@LAZYGIT_DARK_FILE@" wallpaper="@WALLPAPER_DARK_FILE@" apple_dark_mode=true ;; @@ -33,6 +34,7 @@ link_mode_assets() { fzf_target="@FZF_LIGHT_FILE@" ghostty_target="@GHOSTTY_LIGHT_FILE@" tmux_target="@TMUX_LIGHT_FILE@" + lazygit_target="@LAZYGIT_LIGHT_FILE@" wallpaper="@WALLPAPER_LIGHT_FILE@" apple_dark_mode=false ;; @@ -42,17 +44,25 @@ link_mode_assets() { ;; esac - mkdir -p "@STATE_DIR@" "@FZF_DIR@" "@GHOSTTY_DIR@" "@TMUX_DIR@" + mkdir -p "@STATE_DIR@" "@FZF_DIR@" "@GHOSTTY_DIR@" "@TMUX_DIR@" "@LAZYGIT_DIR@" printf '%s\n' "$mode" > "@STATE_FILE@" ln -sfn "$fzf_target" "@FZF_CURRENT_FILE@" ln -sfn "$ghostty_target" "@GHOSTTY_CURRENT_FILE@" ln -sfn "$tmux_target" "@TMUX_CURRENT_FILE@" + ln -sfn "$lazygit_target" "@LAZYGIT_CURRENT_FILE@" if command -v tmux >/dev/null 2>&1 && tmux start-server >/dev/null 2>&1; then tmux source-file "@TMUX_CONFIG@" >/dev/null 2>&1 || true fi if [[ "$(uname -s)" == "Darwin" ]] && command -v osascript >/dev/null 2>&1; then + mkdir -p "@LAZYGIT_DARWIN_DIR@" + if [[ "$mode" == "dark" ]]; then + ln -sfn "@LAZYGIT_DARWIN_DARK_FILE@" "@LAZYGIT_DARWIN_FILE@" + else + ln -sfn "@LAZYGIT_DARWIN_LIGHT_FILE@" "@LAZYGIT_DARWIN_FILE@" + fi + osascript -e "tell application \"System Events\" to tell appearance preferences to set dark mode to ${apple_dark_mode}" >/dev/null 2>&1 || true osascript -e "tell application \"System Events\" to tell every desktop to set picture to \"${wallpaper}\"" >/dev/null 2>&1 || true