Unverified Commit 8dd5f622 authored by figsoda's avatar figsoda Committed by GitHub
Browse files

Merge pull request #220928 from figsoda/starship

parents 3839340f 928c8115
Loading
Loading
Loading
Loading
+21 −4
Original line number Diff line number Diff line
@@ -9,10 +9,27 @@ let

  settingsFile = settingsFormat.generate "starship.toml" cfg.settings;

in {
  initOption =
    if cfg.interactiveOnly then
      "promptInit"
    else
      "shellInit";

in
{
  options.programs.starship = {
    enable = mkEnableOption (lib.mdDoc "the Starship shell prompt");

    interactiveOnly = mkOption {
      default = true;
      example = false;
      type = types.bool;
      description = lib.mdDoc ''
        Whether to enable starship only when the shell is interactive.
        Some plugins require this to be set to false to function correctly.
      '';
    };

    settings = mkOption {
      inherit (settingsFormat) type;
      default = { };
@@ -25,21 +42,21 @@ in {
  };

  config = mkIf cfg.enable {
    programs.bash.promptInit = ''
    programs.bash.${initOption} = ''
      if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
        export STARSHIP_CONFIG=${settingsFile}
        eval "$(${pkgs.starship}/bin/starship init bash)"
      fi
    '';

    programs.fish.promptInit = ''
    programs.fish.${initOption} = ''
      if test "$TERM" != "dumb" -a \( -z "$INSIDE_EMACS" -o "$INSIDE_EMACS" = "vterm" \)
        set -x STARSHIP_CONFIG ${settingsFile}
        eval (${pkgs.starship}/bin/starship init fish)
      end
    '';

    programs.zsh.promptInit = ''
    programs.zsh.${initOption} = ''
      if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
        export STARSHIP_CONFIG=${settingsFile}
        eval "$(${pkgs.starship}/bin/starship init zsh)"