[[ "$TERM" = "xterm" ]] && echo "\[\e]2;PKG(\u)\a\]"
}
+# Draw a horizontal line from the end of the top line of the prompt to
+# the right hand edge of the terminal.
+_hline()
+{
+ # 11 is the number of chars taken up by "-(HH:MM)-()"
+ TRIM=$((${#PWD} + 11))
+
+ # If there was a non-zero return there will be an extra 4 + length
+ # of rc chars
+ [[ $rc -gt 0 ]] && TRIM=$(($TRIM + ${#rc} + 4))
+
+ # Allow for $HOME being displayed as ~
+ [[ $HOME == ${PWD::${#HOME}} ]] && TRIM=$(($TRIM - ${#HOME} + 1))
+
+ a=($(seq -s ' ' 1 $(($COLUMNS - $TRIM))))
+ printf '%s' ${a[@]/*/-}
+}
+
# This function, called from $PROMPT_COMMAND, puts all the pieces of
# the prompt together.
make_prompt()
# Normally you'd define your local vars at the top of the function,
# well I normally do, but in this case it will overwrite the value
# of '$?' so we need to preserve it first.
- local gitp p prc sg title
+ local gitp p prc sg title hline
# Previous cmd's return code, but only if it was non-zero
- [[ $rc -gt 0 ]] && prc="$BWTE[$BRED$rc$BWTE] " || prc=
+ [[ $rc -gt 0 ]] && prc="$BWTE--[$BRED$rc$BWTE]" || prc=
# Using a subgroup
sg=$(_sg)
# Xterm title
title=$(_settitle)
+ # Horizontal line
+ hline=$(_hline)
+
# Build up the PS1
- PS1="$BWTE[$WTE$p $BWTE($CYN\u$sg$BWTE)]" # [pkgusr (usr:grp)]
- PS1+="$CO" # reset to not mess up git prompt
- PS1+="$gitp" # (gitstuff)
- PS1+="\n$prc$BYEL\A$WTE:$BMAG\w$BWTE>$CO " # [rc]TIME:CWD>
- PS1+="$title" # Xterm title
+ PS1="$BWTE-($BYEL\A$BWTE)-($BMAG\w$BWTE)$prc" # -(TIME)-(CWD)--[rc]
+ PS1+="$BBLU$hline\n"
+ PS1+="$BWTE[$YEL$p $BWTE($CYN\u$sg$BWTE)" # [pkgusr (usr:grp)
+ PS1+="$CO" # reset to not mess up git prompt
+ PS1+="$gitp" # (gitstuff)
+ PS1+="$BWTE]>$CO " # ]>
+ PS1+="$title" # Xterm title
}
# The git goodies
GIT_PS1_DESCRIBE_STYLE=branch
GIT_PS1_SHOWCOLORHINTS=true
-# So the prompt doesn't fly off the right-hand edge of the screen
-# when you're down a long directory tree.
-PROMPT_DIRTRIM=4
+# Set this so the prompt doesn't fly off the right-hand edge of the
+# screen when you're down a long directory tree.
+#PROMPT_DIRTRIM=4
# Finally, make the prompt happen!
PROMPT_COMMAND=make_prompt