Minimal_UserHost.bgptheme 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ##############################################################################
  2. # Changes the prompt to a Debian-style one that truncates pwd to a max length
  3. # depending on the terminal column width. Also uses the prompt_callback
  4. # function of bash-git-prompt to set the window title to almost the same
  5. # Debian-style. This version has been tweaked for Ubuntu standard terminal
  6. # fonts.
  7. #
  8. # The prompt will use a Debian-style on the form
  9. #
  10. # relative-path-from-git-toplevel-dir bash-git-prompt-info <exit status>
  11. # HH:MM:SS User@Host ▶
  12. #
  13. # The window title will have the form
  14. # relative-path-from-git-toplevel-dir
  15. #
  16. # Example usage:
  17. # if [ -f ~/.bash-git-prompt/gitprompt.sh ]; then
  18. # GIT_PROMPT_THEME=Minimal_UserHost
  19. # source ~/.bash-git-prompt/gitprompt.sh
  20. # fi
  21. #
  22. # Gert Pellin <gert@pellin.be> [https://github.com/switch87]
  23. #
  24. # Based on Minimal by Imbibinebe <imbibinebe@gmail.com> [https://github.com/imbibinebe]
  25. ##############################################################################
  26. override_git_prompt_colors() {
  27. GIT_PROMPT_THEME_NAME="Minimal_UserHost"
  28. #Overrides the prompt_callback function used by bash-git-prompt
  29. function prompt_callback {
  30. GIT_CONTAINER_FOLDER_FULLPATH=$(git rev-parse --show-toplevel 2> /dev/null)
  31. GIT_CONTAINER_FOLDER=$(basename $GIT_CONTAINER_FOLDER_FULLPATH 2> /dev/null)
  32. CURRENT_FULLPATH=$(pwd)
  33. local PS1=$GIT_CONTAINER_FOLDER${CURRENT_FULLPATH#$GIT_CONTAINER_FOLDER_FULLPATH}
  34. gp_set_window_title "$PS1"
  35. echo -n "${BoldYellow}${PS1}${ResetColor}"
  36. }
  37. Time12a="\$(date +%H:%M:%S)"
  38. if [ "$(id -u)" != "0" ]; then
  39. UserHost_Color="${BoldGreen}"
  40. else
  41. UserHost_Color="${BoldRed}"
  42. fi
  43. GIT_PROMPT_BRANCH="${BoldMagenta}" # the git branch that is active in the current directory
  44. GIT_PROMPT_MASTER_BRANCH="${GIT_PROMPT_MASTER_BRANCH}" # used if the git branch that is active in the current directory is $GIT_PROMPT_MASTER_BRANCHES
  45. GIT_PROMPT_PREFIX="" # start of the git info string
  46. GIT_PROMPT_SUFFIX="" # the end of the git info string
  47. GIT_PROMPT_SEPARATOR="" # separates each item
  48. GIT_PROMPT_STAGED=" ${Green}●" # the number of staged files/directories
  49. GIT_PROMPT_CONFLICTS=" ${BoldRed}✖" # the number of files in conflict
  50. GIT_PROMPT_CHANGED=" ${BoldBlue}✚" # the number of changed files
  51. # GIT_PROMPT_REMOTE=" " # the remote branch name (if any) and the symbols for ahead and behind
  52. GIT_PROMPT_UNTRACKED=" ${Cyan}…" # the number of untracked files/dirs
  53. GIT_PROMPT_STASHED=" ${BoldCyan}⚑" # the number of stashed files/dir
  54. GIT_PROMPT_CLEAN=" ${BoldGreen}✔" # a colored flag indicating a "clean" repo
  55. local gp_end="_LAST_COMMAND_INDICATOR_\n${BoldBlack}${Time12a} ${UserHost_Color}$(whoami)@$(hostname)${ResetColor}"
  56. GIT_PROMPT_START_USER=""
  57. GIT_PROMPT_END_USER="${gp_end} ▶ "
  58. GIT_PROMPT_END_ROOT="${gp_end} /!!!\ "
  59. GIT_PROMPT_COMMAND_OK="${Green} ✔ " # indicator if the last command returned with an exit code of 0
  60. GIT_PROMPT_COMMAND_FAIL="${BoldRed} ✘-_LAST_COMMAND_STATE_" # indicator if the last command returned with an exit code of other than 0
  61. }
  62. reload_git_prompt_colors "Minimal_UserHost"