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,6 +30,19 @@
programs.bash = { programs.bash = {
enableCompletion = true; enableCompletion = true;
promptInit = '' promptInit = ''
function exitstatus() {
if [[ $? -eq 0 ]]; then
printf ''
else
printf ''
fi
}
function nixshellEval {
if [[ "$1" != "" ]]; then
printf "»$1« "
fi
}
function setPS1 {
if test "$TERM" != "dumb"; then if test "$TERM" != "dumb"; then
# Provide a nice prompt. # Provide a nice prompt.
BLUE="\[\033[0;34m\]" BLUE="\[\033[0;34m\]"
@ -39,11 +52,13 @@
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
''; '';
}; };