Skip to content

Commit

Permalink
starship: add nushell integration support
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp-M authored and rycee committed Nov 27, 2022
1 parent 4a12f30 commit 7ae7250
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions modules/programs/starship.nix
Expand Up @@ -89,6 +89,14 @@ in {
Whether to enable Ion integration.
'';
};

enableNushellIntegration = mkOption {
default = true;
type = types.bool;
description = ''
Whether to enable Nushell integration.
'';
};
};

config = mkIf cfg.enable {
Expand Down Expand Up @@ -116,10 +124,21 @@ in {
end
'';

programs.ion.initExtra = mkIf cfg.enableIonIntegration ''
if test $TERM != "dumb" && not exists -s INSIDE_EMACS || test $INSIDE_EMACS = "vterm"
eval $(${starshipCmd} init ion)
end
'';
programs.nushell = mkIf cfg.enableNushellIntegration {
# Unfortunately nushell doesn't allow conditionally sourcing nor
# conditionally setting (global) environment variables, which is why the
# check for terminal compatibility (as seen above for the other shells) is
# not done here.
extraEnv = ''
let starship_cache = "${config.xdg.cacheHome}/starship"
if not ($starship_cache | path exists) {
mkdir $starship_cache
}
${starshipCmd} init nu | save ${config.xdg.cacheHome}/starship/init.nu
'';
extraConfig = ''
source ${config.xdg.cacheHome}/starship/init.nu
'';
};
};
}

0 comments on commit 7ae7250

Please sign in to comment.