From e18635be43d416d110034aabc88e0c1d806da8a2 Mon Sep 17 00:00:00 2001 From: jasmine Date: Mon, 27 Oct 2025 13:56:01 +0800 Subject: [PATCH] refactor(home-manager): refine CLI feature configurations - Add direnv module with nix-direnv integration, replacing manual hook - Disable starship's add_newline for more compact prompt - Clean up comments across CLI features for better readability --- home-manager/sajenim/features/cli/direnv.nix | 15 +++++++++++ .../sajenim/features/cli/starship.nix | 27 +++++++------------ home-manager/sajenim/features/cli/zsh.nix | 2 +- nixos/fuchsia/configuration.nix | 2 -- nixos/viridian/configuration.nix | 2 -- 5 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 home-manager/sajenim/features/cli/direnv.nix diff --git a/home-manager/sajenim/features/cli/direnv.nix b/home-manager/sajenim/features/cli/direnv.nix new file mode 100644 index 0000000..32a2c7b --- /dev/null +++ b/home-manager/sajenim/features/cli/direnv.nix @@ -0,0 +1,15 @@ +{ + # Automatic environment variable management per-directory + programs.direnv = { + enable = true; + + # Faster nix-shell integration with dependency caching + nix-direnv.enable = true; + + # Hook into zsh + enableZshIntegration = true; + + # Suppress logging output + silent = true; + }; +} diff --git a/home-manager/sajenim/features/cli/starship.nix b/home-manager/sajenim/features/cli/starship.nix index 05faee1..03b70df 100644 --- a/home-manager/sajenim/features/cli/starship.nix +++ b/home-manager/sajenim/features/cli/starship.nix @@ -3,13 +3,13 @@ enable = true; enableZshIntegration = true; settings = { - # Left prompt: username@hostname directory git ♥ - format = "$username$hostname$directory$git_branch$git_status$character"; + add_newline = false; - # Right prompt: language indicators + # Prompt layout + format = "$username$hostname$directory$git_branch$git_status$character"; right_format = "$c$direnv$haskell$bun$python$rust"; - # Blue username + # Always show username username = { style_user = "blue"; style_root = "red"; @@ -17,14 +17,14 @@ show_always = true; }; - # Blue @hostname + # Show hostname even when not over SSH hostname = { ssh_only = false; format = "[@$hostname]($style) "; style = "blue"; }; - # Cyan directory + # Full path, no truncation directory = { style = "cyan"; format = "[$path]($style) "; @@ -32,12 +32,10 @@ truncate_to_repo = false; }; - # Git branch (purple, no bold) - git_branch = { - style = "purple"; - }; + # Git configuration + git_branch.style = "purple"; - # Git status with semantic colors (no bold, no brackets) + # Semantic colors for git status indicators git_status = { format = "$conflicted$stashed$deleted$renamed$modified$staged$untracked$ahead_behind"; conflicted = "[=$count](red) "; @@ -52,19 +50,14 @@ deleted = "[✘$count](red) "; }; - # Heart prompt character (red in insert mode, blue in normal mode) + # Vi-mode aware prompt character 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/features/cli/zsh.nix b/home-manager/sajenim/features/cli/zsh.nix index ea1e940..2970b9d 100644 --- a/home-manager/sajenim/features/cli/zsh.nix +++ b/home-manager/sajenim/features/cli/zsh.nix @@ -1,5 +1,6 @@ {pkgs, ...}: { imports = [ + ./direnv.nix ./starship.nix ]; @@ -47,7 +48,6 @@ # Extra commands that should be added to '.zshrc' initContent = '' - eval "$(direnv hook zsh)" bindkey "^[[1;5C" forward-word bindkey "^[[1;5D" backward-word export PATH diff --git a/nixos/fuchsia/configuration.nix b/nixos/fuchsia/configuration.nix index 5b660c4..627b7e0 100644 --- a/nixos/fuchsia/configuration.nix +++ b/nixos/fuchsia/configuration.nix @@ -27,8 +27,6 @@ # Configure programs programs = { zsh.enable = true; - # Load and unload environment variables - direnv.enable = true; # Android debug bridge: communicate with devices adb.enable = true; }; diff --git a/nixos/viridian/configuration.nix b/nixos/viridian/configuration.nix index e52b24b..ca7138c 100644 --- a/nixos/viridian/configuration.nix +++ b/nixos/viridian/configuration.nix @@ -37,8 +37,6 @@ # Configure programs programs = { zsh.enable = true; - # Load and unload environment variables - direnv.enable = true; }; # Manage linux containers