From bdf7c14c6c2ddfadb00b94edfea6ea989be3c2a3 Mon Sep 17 00:00:00 2001 From: jasmine Date: Sat, 25 Oct 2025 23:13:22 +0800 Subject: [PATCH] feat(home-manager): add starship prompt and reorganize CLI features - Move zsh configuration from global/ to features/cli/ - Add starship.nix with custom prompt configuration - Left prompt: username@hostname, directory, git status, vi-mode indicator - Right prompt: language/environment indicators (C, direnv, Haskell, Bun, Python, Rust) - Git status with semantic colors (green=staged, yellow=modified/untracked, red=conflicted/deleted, cyan=stashed/renamed) - Vi-mode aware prompt character (red heart in insert, blue in normal) - Update features/cli to import starship via zsh.nix - Remove empty imports section from global/default.nix --- home-manager/sajenim/features/cli/default.nix | 1 + .../sajenim/features/cli/starship.nix | 70 +++++++++++++++++++ .../sajenim/{global => features/cli}/zsh.nix | 5 +- home-manager/sajenim/global/default.nix | 4 -- 4 files changed, 75 insertions(+), 5 deletions(-) create mode 100644 home-manager/sajenim/features/cli/starship.nix rename home-manager/sajenim/{global => features/cli}/zsh.nix (94%) diff --git a/home-manager/sajenim/features/cli/default.nix b/home-manager/sajenim/features/cli/default.nix index f81e392..731f1c7 100644 --- a/home-manager/sajenim/features/cli/default.nix +++ b/home-manager/sajenim/features/cli/default.nix @@ -7,6 +7,7 @@ ./git.nix ./mpd.nix ./ssh.nix + ./zsh.nix ]; home.packages = with pkgs; diff --git a/home-manager/sajenim/features/cli/starship.nix b/home-manager/sajenim/features/cli/starship.nix new file mode 100644 index 0000000..05faee1 --- /dev/null +++ b/home-manager/sajenim/features/cli/starship.nix @@ -0,0 +1,70 @@ +{...}: { + programs.starship = { + enable = true; + enableZshIntegration = true; + settings = { + # Left prompt: username@hostname directory git ♥ + format = "$username$hostname$directory$git_branch$git_status$character"; + + # Right prompt: language indicators + right_format = "$c$direnv$haskell$bun$python$rust"; + + # Blue username + username = { + style_user = "blue"; + style_root = "red"; + format = "[$user]($style)"; + show_always = true; + }; + + # Blue @hostname + hostname = { + ssh_only = false; + format = "[@$hostname]($style) "; + style = "blue"; + }; + + # Cyan directory + directory = { + style = "cyan"; + format = "[$path]($style) "; + truncation_length = 0; + truncate_to_repo = false; + }; + + # Git branch (purple, no bold) + git_branch = { + style = "purple"; + }; + + # Git status with semantic colors (no bold, no brackets) + git_status = { + format = "$conflicted$stashed$deleted$renamed$modified$staged$untracked$ahead_behind"; + conflicted = "[=$count](red) "; + ahead = "[⇡$count](cyan) "; + behind = "[⇣$count](cyan) "; + diverged = "[⇡$ahead_count](cyan)[⇣$behind_count](cyan) "; + untracked = "[?$count](yellow) "; + stashed = "[\\$$count](cyan) "; + modified = "[!$count](yellow) "; + staged = "[+$count](green) "; + renamed = "[»$count](cyan) "; + deleted = "[✘$count](red) "; + }; + + # Heart prompt character (red in insert mode, blue in normal mode) + character = { + success_symbol = "[♥](red)"; + error_symbol = "[♥](red)"; + vicmd_symbol = "[♥](blue)"; + }; + + # Language modules for right prompt (only configure non-defaults) + + # Enable direnv (disabled by default) + direnv.disabled = false; + + # C, Python, Haskell, Bun, Rust: use defaults + }; + }; +} diff --git a/home-manager/sajenim/global/zsh.nix b/home-manager/sajenim/features/cli/zsh.nix similarity index 94% rename from home-manager/sajenim/global/zsh.nix rename to home-manager/sajenim/features/cli/zsh.nix index b8ad532..ea1e940 100644 --- a/home-manager/sajenim/global/zsh.nix +++ b/home-manager/sajenim/features/cli/zsh.nix @@ -1,4 +1,8 @@ {pkgs, ...}: { + imports = [ + ./starship.nix + ]; + home.packages = with pkgs; [ fzf # command-line fuzzy finder ]; @@ -47,7 +51,6 @@ bindkey "^[[1;5C" forward-word bindkey "^[[1;5D" backward-word export PATH - PROMPT='%F{blue}%n@%m %F{cyan}%~ %F{red}♥ %f'; ''; }; } diff --git a/home-manager/sajenim/global/default.nix b/home-manager/sajenim/global/default.nix index d938728..6ae7abe 100644 --- a/home-manager/sajenim/global/default.nix +++ b/home-manager/sajenim/global/default.nix @@ -2,10 +2,6 @@ # This module provides base user settings, nixpkgs configuration, and core imports # that are inherited across all hosts where this user is configured. {outputs, lib, ...}: { - imports = [ - ./zsh.nix # Shell configuration and plugins - ]; - # Nixpkgs configuration - applies overlays and sets package acceptance policy nixpkgs = { # Apply custom overlays to extend/modify the package set