my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.9 KiB

3 years ago
  1. #!/usr/bin/env zsh
  2. # #
  3. # # #README
  4. # #
  5. # # This theme provides two customizable header functionalities:
  6. # # a) displaying a pseudo-random message from a database of quotations
  7. # # (https://en.wikipedia.org/wiki/Fortune_%28Unix%29)
  8. # # b) displaying randomly command line tips from The command line fu
  9. # # (https://www.commandlinefu.com) community: in order to make use of this functionality
  10. # # you will need Internet connection.
  11. # # This theme provides as well information for the current user's context, like;
  12. # # branch and status for the current version control system (git and svn currently
  13. # # supported) and time, presented to the user in a non invasive volatile way.
  14. # #
  15. # # #REQUIREMENTS
  16. # # This theme requires wget::
  17. # # -Homebrew-osx- brew install wget
  18. # # -Debian/Ubuntu- apt-get install wget
  19. # # and fortune ::
  20. # # -Homebrew-osx- brew install fortune
  21. # # -Debian/Ubuntu- apt-get install fortune
  22. # #
  23. # # optionally:
  24. # # -Oh-myzsh vcs plug-ins git and svn.
  25. # # -Solarized theme (https://github.com/altercation/solarized/)
  26. # # -OS X: iTerm 2 (https://iterm2.com/)
  27. # # -font Source code pro (https://github.com/adobe/source-code-pro)
  28. # #
  29. # # This theme's look and feel is based on the Aaron Toponce's zsh theme, more info:
  30. # # https://pthree.org/2008/11/23/727/
  31. # # enjoy!
  32. ########## COLOR ###########
  33. for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do
  34. typeset -g PR_$COLOR="%b%{$fg[${(L)COLOR}]%}"
  35. typeset -g PR_BRIGHT_$COLOR="%B%{$fg[${(L)COLOR}]%}"
  36. done
  37. PR_RESET="%{$reset_color%}"
  38. RED_START="${PR_GREY}<${PR_RED}<${PR_BRIGHT_RED}<${PR_RESET} "
  39. RED_END="${PR_BRIGHT_RED}>${PR_RED}>${PR_GREY}>${PR_RESET} "
  40. GREEN_START="${PR_GREY}>${PR_GREEN}>${PR_BRIGHT_GREEN}>${PR_RESET}"
  41. GREEN_END="${PR_BRIGHT_GREEN}>${PR_GREEN}>${PR_GREY}>${PR_RESET} "
  42. ########## VCS ###########
  43. VCS_DIRTY_COLOR="${PR_YELLOW}"
  44. VCS_CLEAN_COLOR="${PR_GREEN}"
  45. VCS_SUFFIX_COLOR="${PR_RED}› ${PR_RESET}"
  46. ########## SVN ###########
  47. ZSH_THEME_SVN_PROMPT_PREFIX="${PR_RED}‹svn:"
  48. ZSH_THEME_SVN_PROMPT_SUFFIX="${VCS_SUFFIX_COLOR}"
  49. ZSH_THEME_SVN_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘"
  50. ZSH_THEME_SVN_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔"
  51. ########## GIT ###########
  52. ZSH_THEME_GIT_PROMPT_PREFIX="${PR_RED}‹git:"
  53. ZSH_THEME_GIT_PROMPT_SUFFIX="${VCS_SUFFIX_COLOR}"
  54. ZSH_THEME_GIT_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘"
  55. ZSH_THEME_GIT_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔"
  56. ZSH_THEME_GIT_PROMPT_ADDED="${PR_YELLOW} ✚"
  57. ZSH_THEME_GIT_PROMPT_MODIFIED="${PR_YELLOW} ✹"
  58. ZSH_THEME_GIT_PROMPT_DELETED="${PR_YELLOW} ✖"
  59. ZSH_THEME_GIT_PROMPT_RENAMED="${PR_YELLOW} ➜"
  60. ZSH_THEME_GIT_PROMPT_UNMERGED="${PR_YELLOW} ═"
  61. ZSH_THEME_GIT_PROMPT_UNTRACKED="${PR_YELLOW} ✭"
  62. # Get a fortune quote
  63. ps1_fortune() {
  64. if (( ${+commands[fortune]} )); then
  65. fortune
  66. fi
  67. }
  68. # Obtain a command tip
  69. ps1_command_tip() {
  70. {
  71. if (( ${+commands[wget]} )); then
  72. command wget -qO- https://www.commandlinefu.com/commands/random/plaintext
  73. elif (( ${+commands[curl]} )); then
  74. command curl -fsL https://www.commandlinefu.com/commands/random/plaintext
  75. fi
  76. } | sed '1d;/^$/d'
  77. }
  78. # Show prompt header (fortune / command tip)
  79. prompt_header() {
  80. local header=$(
  81. case "${ENABLE_COMMAND_TIP:-}" in
  82. true) ps1_command_tip ;;
  83. *) ps1_fortune ;;
  84. esac
  85. )
  86. # Make sure to quote % so that they're not expanded by the prompt
  87. echo -n "${header:gs/%/%%}"
  88. }
  89. # Context: user@directory or just directory
  90. prompt_context() {
  91. if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
  92. echo -n "${PR_RESET}${PR_RED}%n@%m"
  93. fi
  94. }
  95. ########## SETUP ###########
  96. # Required for the prompt
  97. setopt prompt_subst
  98. # Prompt: header, context (user@host), directory
  99. PROMPT="${RED_START}${PR_YELLOW}\$(prompt_header)${PR_RESET}
  100. ${RED_START}\$(prompt_context)${PR_BRIGHT_YELLOW}%~${PR_RESET}
  101. ${GREEN_START} "
  102. # Right prompt: vcs status + time
  103. RPROMPT="\$(git_prompt_info)\$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}"
  104. # Matching continuation prompt
  105. PROMPT2="${GREEN_START} %_ ${GREEN_START} "