TruncatedPwd_WindowTitle_NoExitState.bgptheme 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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.
  6. #
  7. # The prompt will use a Debian-style on the form
  8. #
  9. # [user@host: <truncated PWD>] [bash-git-prompt-info]
  10. # HH:MM $
  11. #
  12. # The window title will have the form
  13. # user@host: <truncated PWD>
  14. #
  15. # Example usage:
  16. # if [ -f ~/.bash-git-prompt/gitprompt.sh ]; then
  17. # GIT_PROMPT_THEME=TruncatedPwd_WindowTitle_NoExitState
  18. # source ~/.bash-git-prompt/gitprompt.sh
  19. # fi
  20. #
  21. # oGre <oGre@muppfarmen.se> [https://github.com/ogr3]
  22. ##############################################################################
  23. override_git_prompt_colors() {
  24. GIT_PROMPT_THEME_NAME="TruncatedPwd_WindowTitle_NoExitState"
  25. #Overrides the prompt_callback function used by bash-git-prompt
  26. function prompt_callback {
  27. local PS1="\u@\h: $(gp_truncate_pwd)"
  28. gp_set_window_title "${PS1}"
  29. echo -n "${Yellow}[${PS1}]${ResetColor}"
  30. }
  31. local gp_end=" _LAST_COMMAND_INDICATOR_\n${White}${Time12a}${ResetColor}"
  32. GIT_PROMPT_START_USER=""
  33. GIT_PROMPT_END_USER="${gp_end} $ "
  34. GIT_PROMPT_END_ROOT="${gp_end} # "
  35. }
  36. reload_git_prompt_colors "TruncatedPwd_WindowTitle_NoExitState"