Skip to content
This repository
Newer
Older
100644 85 lines (73 sloc) 3.635 kb
16f9dfb3 » dogenpunk
2011-03-31 Adding dogenpunk theme
1 # -----------------------------------------------------------------------------
2 # FILE: dogenpunk.zsh-theme
3 # DESCRIPTION: oh-my-zsh theme file.
4 # AUTHOR: Matthew Nelson (dogenpunk@gmail.com)
5 # VERSION: 0.1
6 # SCREENSHOT: coming soon
7 # -----------------------------------------------------------------------------
8
9 MODE_INDICATOR="%{$fg_bold[red]%}❮%{$reset_color%}%{$fg[red]%}❮❮%{$reset_color%}"
10 local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%}"
11
12 PROMPT='%{$fg[blue]%}%m%{$reset_color%}%{$fg_bold[white]%} ओम् %{$reset_color%}%{$fg[cyan]%}%~:%{$reset_color%}$(git_time_since_commit)$(git_prompt_info)
13 %{$fg[red]%}%!%{$reset_color%} $(prompt_char) '
14
15 ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[green]%}git%{$reset_color%}@%{$bg[white]%}%{$fg[black]%}"
16 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%})"
17 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}!%{$reset_color%}"
18 ZSH_THEME_GIT_PROMPT_CLEAN=""
19
20 RPROMPT='${return_status}$(git_prompt_status)%{$reset_color%}'
21
22 ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚"
23 ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹"
24 ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖"
25 ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜"
26 ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═"
27 ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"
28
29 function prompt_char() {
30 git branch >/dev/null 2>/dev/null && echo "%{$fg[green]%}±%{$reset_color%}" && return
31 hg root >/dev/null 2>/dev/null && echo "%{$fg_bold[red]%}☿%{$reset_color%}" && return
32 echo "%{$fg[cyan]%}◯ %{$reset_color%}"
33 }
34
35 # Colors vary depending on time lapsed.
36 ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
37 ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
38 ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
39 ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[cyan]%}"
40
41 # Determine the time since last commit. If branch is clean,
42 # use a neutral color, otherwise colors will vary according to time.
43 function git_time_since_commit() {
44 if git rev-parse --git-dir > /dev/null 2>&1; then
45 # Only proceed if there is actually a commit.
46 if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
47 # Get the last commit.
48 last_commit=`git log --pretty=format:'%at' -1 2> /dev/null`
49 now=`date +%s`
50 seconds_since_last_commit=$((now-last_commit))
51
52 # Totals
53 MINUTES=$((seconds_since_last_commit / 60))
54 HOURS=$((seconds_since_last_commit/3600))
55
56 # Sub-hours and sub-minutes
57 DAYS=$((seconds_since_last_commit / 86400))
58 SUB_HOURS=$((HOURS % 24))
59 SUB_MINUTES=$((MINUTES % 60))
60
61 if [[ -n $(git status -s 2> /dev/null) ]]; then
62 if [ "$MINUTES" -gt 30 ]; then
63 COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG"
64 elif [ "$MINUTES" -gt 10 ]; then
65 COLOR="$ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM"
66 else
67 COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT"
68 fi
69 else
70 COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
71 fi
72
73 if [ "$HOURS" -gt 24 ]; then
74 echo "($COLOR${DAYS}d${SUB_HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
75 elif [ "$MINUTES" -gt 60 ]; then
76 echo "($COLOR${HOURS}h${SUB_MINUTES}m%{$reset_color%}|"
77 else
78 echo "($COLOR${MINUTES}m%{$reset_color%}|"
79 fi
80 else
81 COLOR="$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL"
82 echo "($COLOR~|"
83 fi
84 fi
85 }
Something went wrong with that request. Please try again.