steveej-laptop/system: rework PS1
This commit is contained in:
parent
1f96268722
commit
f297250356
1 changed files with 28 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue