prompt.bash 603 B

12345678910111213141516171819202122
  1. # Command Prompt
  2. #
  3. # [host] directory gitinfo jobinfo
  4. # user -
  5. #
  6. PROMPT_COMMAND='PS1="
  7. ${FG[6]}[\h] ${FG[3]}$(shortcwd)$(__gitp " %s")$(getajob)
  8. ${FG[5]}\u - $cReset";'$PROMPT_COMMAND
  9. # Display suspended/backgrounded job count, if any.
  10. function getajob() {
  11. local jobcount=$(jobs | wc -l)
  12. [[ $jobcount -ne 0 ]] && printf " ${FG[63]}[jobs]: ${FG[1]}\j" || printf ''
  13. }
  14. # Display up to 3 segments of the current working directory.
  15. function shortcwd() {
  16. local fld='[^/]*'
  17. folder=${PWD/$HOME/"~"}
  18. folder=$(echo $folder | sed 's|.*/\('$fld'/'$fld'/'$fld'\)|\1|')
  19. printf "$folder"
  20. }