diff --git a/modules/programs/bash/bash.nix b/modules/programs/bash/bash.nix index 441d30f1e9f..135d99ec437 100644 --- a/modules/programs/bash/bash.nix +++ b/modules/programs/bash/bash.nix @@ -25,9 +25,24 @@ let fi ''; - options = { + environment.promptInit = mkOption { + default = '' + # Provide a nice prompt. + PROMPT_COLOR="1;31m" + let $UID && PROMPT_COLOR="1;32m" + PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] " + if test "$TERM" = "xterm"; then + PS1="\[\033]2;\h:\u:\w\007\]$PS1" + fi + ''; + description = " + Script used to initialized shell prompt. + "; + type = with pkgs.lib.types; string; + }; + environment.shellInit = mkOption { default = ""; example = ''export PATH=/godi/bin/:$PATH''; @@ -65,6 +80,7 @@ in # configured properly. source = pkgs.substituteAll { src = ./bashrc.sh; + inherit (config.environment) promptInit; inherit initBashCompletion; }; target = "bashrc"; diff --git a/modules/programs/bash/bashrc.sh b/modules/programs/bash/bashrc.sh index 10a36ede2a3..3542b5f9fd4 100644 --- a/modules/programs/bash/bashrc.sh +++ b/modules/programs/bash/bashrc.sh @@ -19,14 +19,7 @@ if [ -z "$PS1" ]; then return; fi # Check the window size after every command. shopt -s checkwinsize -# Provide a nice prompt. -PROMPT_COLOR="1;31m" -let $UID && PROMPT_COLOR="1;32m" -PS1="\n\[\033[$PROMPT_COLOR\][\u@\h:\w]\\$\[\033[0m\] " -if test "$TERM" = "xterm"; then - PS1="\[\033]2;\h:\u:\w\007\]$PS1" -fi - +@promptInit@ @initBashCompletion@ # Some aliases.