From c538cb82115fb6352c34257dfab6716a5a123b29 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Thu, 5 Jun 2025 09:28:57 +0800 Subject: [PATCH] Enable transience feature for starship. --- home/modules/programs/starship/default.nix | 45 ++++++++++++++-------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/home/modules/programs/starship/default.nix b/home/modules/programs/starship/default.nix index ec6d055..d41b42b 100644 --- a/home/modules/programs/starship/default.nix +++ b/home/modules/programs/starship/default.nix @@ -4,27 +4,40 @@ ... }: let cfg = config.youthlic.programs.starship; + fish-cfg = config.youthlic.programs.fish; + bash-cfg = config.youthlic.programs.bash; in { options = { youthlic.programs.starship = { enable = lib.mkEnableOption "starship"; }; }; - config = lib.mkIf cfg.enable { - programs.starship = lib.mkMerge [ - { - enable = true; - settings = let - config-file = builtins.readFile ./config.toml; - in - builtins.fromTOML config-file; + config = lib.mkMerge [ + ( + lib.mkIf cfg.enable { + programs.starship = { + enable = true; + enableTransience = true; + settings = let + config-file = builtins.readFile ./config.toml; + in + builtins.fromTOML config-file; + }; } - (lib.mkIf config.youthlic.programs.fish.enable { - enableFishIntegration = true; - }) - (lib.mkIf config.youthlic.programs.bash.enable { - enableBashIntegration = true; - }) - ]; - }; + ) + (lib.mkIf (cfg.enable && fish-cfg.enable) { + programs.starship.enableFishIntegration = true; + programs.fish.functions = { + starship_transient_prompt_func = '' + starship module character + ''; + starship_transient_rprompt_func = '' + starship module time + ''; + }; + }) + (lib.mkIf (cfg.enable && bash-cfg.enable) { + programs.starship.enableBashIntegration = true; + }) + ]; }