diff --git a/configuration/steveej-laptop/system.nix b/configuration/steveej-laptop/system.nix index 7572ae9..354d999 100644 --- a/configuration/steveej-laptop/system.nix +++ b/configuration/steveej-laptop/system.nix @@ -30,21 +30,36 @@ programs.bash = { enableCompletion = true; promptInit = '' - 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\]" + 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 + # Provide a nice prompt. + BLUE="\[\033[0;34m\]" + RED="\[\033[1;31m\]" + GREEN="\[\033[1;32m\]" + NO_COLOR="\[\033[0m\]" - PROMPT_COLOR=$RED - let $UID && PROMPT_COLOR=$GREEN - PS1=" $BLUE\W/ $PROMPT_COLOR\\$ $NO_COLOR" - if test "$TERM" = "xterm"; then - PS1="\[\033]2;\h:\u:\w\007\]$PS1" - fi + PROMPT_COLOR=$RED + let $UID && PROMPT_COLOR=$GREEN + PS1="$PROMPT_COLOR\u$NO_COLOR@\h \$(exitstatus) \$(nixshellEval $1)$BLUE\w$NO_COLOR\n$PROMPT_COLOR\\$ $NO_COLOR" + if test "$TERM" = "xterm"; then + PS1="\[\033]2;\h:\u:\w\007\]$PS1" fi - ''; + fi + } + setPS1 + ''; }; # Package configuration