Added environment.promptInit to allow PS1 overriding. Would be nicer to be able to allow overriding via shellInit, however could not get that to work. For now this is a temporary solution which will not break anything.

This commit is contained in:
Rob Vermaas 2012-10-30 13:33:37 +01:00
parent 1a82024dd8
commit 88a9d7a9ca
2 changed files with 18 additions and 9 deletions

View file

@ -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";

View file

@ -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.