diff --git a/modules/cli/shell/starship.nix b/modules/cli/shell/starship.nix index 4aaf255..fe3361a 100644 --- a/modules/cli/shell/starship.nix +++ b/modules/cli/shell/starship.nix @@ -11,17 +11,26 @@ in }; config = lib.mkMerge [ - { - my.cli.shell.starship.format = lib.mkOrder 0 [ "$all" ]; - } (lib.mkIf cfg.enable { my.hm = { programs.starship = { enable = true; settings = lib.recursiveUpdate (with builtins; fromTOML (readFile ./starship-preset.toml)) { add_newline = false; + command_timeout = 2000; nix_shell.disabled = true; - format = lib.concatStringsSep "" cfg.format; + format = let + dedupDollar = list: let + result = builtins.foldl' (acc: elem: + if lib.hasPrefix "$" elem then + if builtins.elem elem acc.seen + then acc + else acc // { result = acc.result ++ [elem]; seen = acc.seen ++ [elem]; } + else + acc // { result = acc.result ++ [elem]; } + ) { result = []; seen = []; } (lib.reverseList list); + in lib.reverseList result.result; + in "$all" + lib.concatStrings (dedupDollar cfg.format); }; }; }; diff --git a/modules/cli/shpool.nix b/modules/cli/shpool.nix index d916421..94aee1a 100644 --- a/modules/cli/shpool.nix +++ b/modules/cli/shpool.nix @@ -22,20 +22,19 @@ in forward_env = [ "PATH" ]; }; }; - # https://github.com/starship/starship/discussions/7260 - # programs.starship = { - # settings = { - # custom.shpool = { - # description = "Display current shpool session name"; - # when = ''test -n "$SHPOOL_SESSION_NAME"''; - # command = "echo $SHPOOL_SESSION_NAME"; - # symbol = " "; - # style = "fg:#dea584"; - # format = "[$symbol $output]($style)"; - # }; - # }; - # }; + programs.starship = { + settings = { + custom.shpool = { + description = "Display current shpool session name"; + when = ''test -n "$SHPOOL_SESSION_NAME"''; + command = "echo $SHPOOL_SESSION_NAME"; + symbol = " "; + style = "fg:#dea584"; + format = "[$symbol \\[$output\\] ]($style)"; + }; + }; + }; }; - # my.cli.shell.starship.format = [ "$starship$character" ]; + my.cli.shell.starship.format = [ "\${custom.shpool}" "$character" ]; }; } diff --git a/modules/cli/tmux.nix b/modules/cli/tmux.nix index 1949364..9592f88 100644 --- a/modules/cli/tmux.nix +++ b/modules/cli/tmux.nix @@ -34,20 +34,19 @@ in }) ]; }; - # https://github.com/starship/starship/discussions/7260 - # programs.starship = { - # settings = { - # custom.tmux = { - # description = "Display current tmux session name"; - # when = ''test -n "$TMUX"''; - # command = "tmux display-message -p '#S'"; - # symbol = " "; - # style = "bold green"; - # format = "[$symbol $output]($style)"; - # }; - # }; - # }; + programs.starship = { + settings = { + custom.tmux = { + description = "Display current tmux session name"; + when = ''test -n "$TMUX"''; + command = "tmux display-message -p '#S'"; + symbol = " "; + style = "bold green"; + format = "[$symbol \\[$output\\] ]($style)"; + }; + }; + }; }; - # my.cli.shell.starship.format = [ "$tmux$character" ]; + my.cli.shell.starship.format = [ "\${custom.tmux}" "$character" ]; }; }