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.
16 # # This theme requires wget::
17 # # -Homebrew-osx- brew install wget
18 # # -Debian/Ubuntu- apt-get install wget
20 # # -Homebrew-osx- brew install fortune
21 # # -Debian/Ubuntu- apt-get install fortune
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)
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/
33 ########## COLOR ###########
34 for COLOR in CYAN WHITE YELLOW MAGENTA BLACK BLUE RED DEFAULT GREEN GREY; do
35 typeset -g PR_$COLOR="%b%{$fg[${(L)COLOR}]%}"
36 typeset -g PR_BRIGHT_$COLOR="%B%{$fg[${(L)COLOR}]%}"
38 PR_RESET="%{$reset_color%}"
40 RED_START="${PR_GREY}<${PR_RED}<${PR_BRIGHT_RED}<${PR_RESET} "
41 RED_END="${PR_BRIGHT_RED}>${PR_RED}>${PR_GREY}>${PR_RESET} "
42 GREEN_START="${PR_GREY}>${PR_GREEN}>${PR_BRIGHT_GREEN}>${PR_RESET}"
43 GREEN_END="${PR_BRIGHT_GREEN}>${PR_GREEN}>${PR_GREY}>${PR_RESET} "
45 ########## VCS ###########
46 VCS_DIRTY_COLOR="${PR_YELLOW}"
47 VCS_CLEAN_COLOR="${PR_GREEN}"
48 VCS_SUFFIX_COLOR="${PR_RED}› ${PR_RESET}"
50 ########## SVN ###########
51 ZSH_THEME_SVN_PROMPT_PREFIX="${PR_RED}‹svn:"
52 ZSH_THEME_SVN_PROMPT_SUFFIX="${VCS_SUFFIX_COLOR}"
53 ZSH_THEME_SVN_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘"
54 ZSH_THEME_SVN_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔"
56 ########## GIT ###########
57 ZSH_THEME_GIT_PROMPT_PREFIX="${PR_RED}‹git:"
58 ZSH_THEME_GIT_PROMPT_SUFFIX="${VCS_SUFFIX_COLOR}"
59 ZSH_THEME_GIT_PROMPT_DIRTY="${VCS_DIRTY_COLOR} ✘"
60 ZSH_THEME_GIT_PROMPT_CLEAN="${VCS_CLEAN_COLOR} ✔"
61 ZSH_THEME_GIT_PROMPT_ADDED="${PR_YELLOW} ✚"
62 ZSH_THEME_GIT_PROMPT_MODIFIED="${PR_YELLOW} ✹"
63 ZSH_THEME_GIT_PROMPT_DELETED="${PR_YELLOW} ✖"
64 ZSH_THEME_GIT_PROMPT_RENAMED="${PR_YELLOW} ➜"
65 ZSH_THEME_GIT_PROMPT_UNMERGED="${PR_YELLOW} ═"
66 ZSH_THEME_GIT_PROMPT_UNTRACKED="${PR_YELLOW} ✭"
70 if (( ${+commands[fortune]} )); then
75 # Obtain a command tip
78 if (( ${+commands[wget]} )); then
79 command wget -qO- https://www.commandlinefu.com/commands/random/plaintext
80 elif (( ${+commands[curl]} )); then
81 command curl -fsL https://www.commandlinefu.com/commands/random/plaintext
86 # Show prompt header (fortune / command tip)
89 case "${ENABLE_COMMAND_TIP:-}" in
90 true) ps1_command_tip ;;
95 # Make sure to quote % so that they're not expanded by the prompt
96 echo -n "${header:gs/%/%%}"
99 # Context: user@directory or just directory
101 if [[ "$USERNAME" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
102 echo -n "${PR_RESET}${PR_RED}%n@%m"
106 ########## SETUP ###########
108 # Required for the prompt
111 # Prompt: header, context (user@host), directory
112 PROMPT="${RED_START}${PR_YELLOW}\$(prompt_header)${PR_RESET}
113 ${RED_START}\$(prompt_context)${PR_BRIGHT_YELLOW}%~${PR_RESET}
115 # Right prompt: vcs status + time
116 RPROMPT="\$(git_prompt_info)\$(svn_prompt_info)${PR_YELLOW}%D{%R.%S %a %b %d %Y} ${GREEN_END}"
117 # Matching continuation prompt
118 PROMPT2="${GREEN_START} %_ ${GREEN_START} "