steveej-laptop/system: rework PS1

This commit is contained in:
steveej 2016-05-23 00:35:47 +02:00
parent 1f96268722
commit f297250356

View file

@ -30,21 +30,36 @@
programs.bash = { programs.bash = {
enableCompletion = true; enableCompletion = true;
promptInit = '' promptInit = ''
if test "$TERM" != "dumb"; then function exitstatus() {
# Provide a nice prompt. if [[ $? -eq 0 ]]; then
BLUE="\[\033[0;34m\]" printf ''
RED="\[\033[1;31m\]" else
GREEN="\[\033[1;32m\]" printf ''
NO_COLOR="\[\033[0m\]" fi
}
function nixshellEval {
if [[ "$1" != "" ]]; then
printf "»$1« "
fi
}
function setPS1 {
if test "$TERM" != "dumb"; then
# Provide a nice prompt.
BLUE="\[\033[0;34m\]"
RED="\[\033[1;31m\]"
GREEN="\[\033[1;32m\]"
NO_COLOR="\[\033[0m\]"
PROMPT_COLOR=$RED PROMPT_COLOR=$RED
let $UID && PROMPT_COLOR=$GREEN let $UID && PROMPT_COLOR=$GREEN
PS1=" $BLUE\W/ $PROMPT_COLOR\\$ $NO_COLOR" PS1="$PROMPT_COLOR\u$NO_COLOR@\h \$(exitstatus) \$(nixshellEval $1)$BLUE\w$NO_COLOR\n$PROMPT_COLOR\\$ $NO_COLOR"
if test "$TERM" = "xterm"; then if test "$TERM" = "xterm"; then
PS1="\[\033]2;\h:\u:\w\007\]$PS1" PS1="\[\033]2;\h:\u:\w\007\]$PS1"
fi
fi fi
''; fi
}
setPS1
'';
}; };
# Package configuration # Package configuration