cd3b658167
Many of the terminals supported inside emacs work perfectly fine with STARSHIP. The TERM=dumb case already handles the tramp and eterm cases, so as far as I can tell, this is basically just a check for the benefit of OLD versions of term-mode (see https://www.emacswiki.org/emacs/AnsiTerm#:~:text=Historically%2C%20'M%2Dx%20ansi%2Dterm,the%20older%20'C%2Dc'%20binding., which indicates that it also now handles colors)
68 lines
1.6 KiB
Nix
68 lines
1.6 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.programs.starship;
|
|
|
|
settingsFormat = pkgs.formats.toml { };
|
|
|
|
settingsFile = settingsFormat.generate "starship.toml" cfg.settings;
|
|
|
|
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 = { };
|
|
description = lib.mdDoc ''
|
|
Configuration included in `starship.toml`.
|
|
|
|
See https://starship.rs/config/#prompt for documentation.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
programs.bash.${initOption} = ''
|
|
if [[ $TERM != "dumb" ]]; then
|
|
export STARSHIP_CONFIG=${settingsFile}
|
|
eval "$(${pkgs.starship}/bin/starship init bash)"
|
|
fi
|
|
'';
|
|
|
|
programs.fish.${initOption} = ''
|
|
if test "$TERM" != "dumb"
|
|
set -x STARSHIP_CONFIG ${settingsFile}
|
|
eval (${pkgs.starship}/bin/starship init fish)
|
|
end
|
|
'';
|
|
|
|
programs.zsh.${initOption} = ''
|
|
if [[ $TERM != "dumb" ]]; then
|
|
export STARSHIP_CONFIG=${settingsFile}
|
|
eval "$(${pkgs.starship}/bin/starship init zsh)"
|
|
fi
|
|
'';
|
|
};
|
|
|
|
meta.maintainers = pkgs.starship.meta.maintainers;
|
|
}
|