mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-16 06:29:17 +03:00
nixos/starship: add interactiveOnly option
This commit is contained in:
parent
26d9471ea9
commit
928c8115ba
1 changed files with 21 additions and 4 deletions
|
@ -9,10 +9,27 @@ let
|
||||||
|
|
||||||
settingsFile = settingsFormat.generate "starship.toml" cfg.settings;
|
settingsFile = settingsFormat.generate "starship.toml" cfg.settings;
|
||||||
|
|
||||||
in {
|
initOption =
|
||||||
|
if cfg.interactiveOnly then
|
||||||
|
"promptInit"
|
||||||
|
else
|
||||||
|
"shellInit";
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
options.programs.starship = {
|
options.programs.starship = {
|
||||||
enable = mkEnableOption (lib.mdDoc "the Starship shell prompt");
|
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 {
|
settings = mkOption {
|
||||||
inherit (settingsFormat) type;
|
inherit (settingsFormat) type;
|
||||||
default = { };
|
default = { };
|
||||||
|
@ -25,21 +42,21 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
programs.bash.promptInit = ''
|
programs.bash.${initOption} = ''
|
||||||
if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
|
if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
|
||||||
export STARSHIP_CONFIG=${settingsFile}
|
export STARSHIP_CONFIG=${settingsFile}
|
||||||
eval "$(${pkgs.starship}/bin/starship init bash)"
|
eval "$(${pkgs.starship}/bin/starship init bash)"
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
programs.fish.promptInit = ''
|
programs.fish.${initOption} = ''
|
||||||
if test "$TERM" != "dumb" -a \( -z "$INSIDE_EMACS" -o "$INSIDE_EMACS" = "vterm" \)
|
if test "$TERM" != "dumb" -a \( -z "$INSIDE_EMACS" -o "$INSIDE_EMACS" = "vterm" \)
|
||||||
set -x STARSHIP_CONFIG ${settingsFile}
|
set -x STARSHIP_CONFIG ${settingsFile}
|
||||||
eval (${pkgs.starship}/bin/starship init fish)
|
eval (${pkgs.starship}/bin/starship init fish)
|
||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
|
|
||||||
programs.zsh.promptInit = ''
|
programs.zsh.${initOption} = ''
|
||||||
if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
|
if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
|
||||||
export STARSHIP_CONFIG=${settingsFile}
|
export STARSHIP_CONFIG=${settingsFile}
|
||||||
eval "$(${pkgs.starship}/bin/starship init zsh)"
|
eval "$(${pkgs.starship}/bin/starship init zsh)"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue