summaryrefslogtreecommitdiff
path: root/themes/avit.zsh-theme
diff options
context:
space:
mode:
Diffstat (limited to 'themes/avit.zsh-theme')
-rw-r--r--themes/avit.zsh-theme81
1 files changed, 29 insertions, 52 deletions
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index aec14e4a6..0261f0ff3 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -1,27 +1,20 @@
# AVIT ZSH Theme
-PROMPT='
-$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
-%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} '
-
-PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} '
+# settings
+typeset +H _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
+typeset +H _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
+typeset +H _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
-RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
+PROMPT='
+$(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
+%{%(!.%F{red}.%F{white})%}▶%{$resetcolor%} '
-local _current_dir="%{$fg_bold[blue]%}%3~%{$reset_color%} "
-local _return_status="%{$fg_bold[red]%}%(?..⍉)%{$reset_color%}"
-local _hist_no="%{$fg[grey]%}%h%{$reset_color%}"
+PROMPT2='%{%(!.%F{red}.%F{white})%}◀%{$reset_color%} '
-function _current_dir() {
- local _max_pwd_length="65"
- if [[ $(echo -n $PWD | wc -c) -gt ${_max_pwd_length} ]]; then
- echo "%{$fg_bold[blue]%}%-2~ ... %3~%{$reset_color%} "
- else
- echo "%{$fg_bold[blue]%}%~%{$reset_color%} "
- fi
-}
+RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
function _user_host() {
+ local me
if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m"
elif [[ $LOGNAME != $USER ]]; then
@@ -32,61 +25,41 @@ function _user_host() {
fi
}
-function _vi_status() {
- if {echo $fpath | grep -q "plugins/vi-mode"}; then
- echo "$(vi_mode_prompt_info)"
- fi
-}
-
-function _ruby_version() {
- if {echo $fpath | grep -q "plugins/rvm"}; then
- echo "%{$fg[grey]%}$(rvm_prompt_info)%{$reset_color%}"
- elif {echo $fpath | grep -q "plugins/rbenv"}; then
- echo "%{$fg[grey]%}$(rbenv_prompt_info)%{$reset_color%}"
- fi
-}
-
# Determine the time since last commit. If branch is clean,
# use a neutral color, otherwise colors will vary according to time.
function _git_time_since_commit() {
-# Only proceed if there is actually a commit.
+ local last_commit now seconds_since_last_commit
+ local minutes hours days years commit_age
+ # Only proceed if there is actually a commit.
if last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null); then
now=$(date +%s)
seconds_since_last_commit=$((now-last_commit))
# Totals
minutes=$((seconds_since_last_commit / 60))
- hours=$((seconds_since_last_commit/3600))
-
- # Sub-hours and sub-minutes
- days=$((seconds_since_last_commit / 86400))
- sub_hours=$((hours % 24))
- sub_minutes=$((minutes % 60))
-
- if [ $hours -ge 24 ]; then
- commit_age="${days}d"
- elif [ $minutes -gt 60 ]; then
- commit_age="${sub_hours}h${sub_minutes}m"
+ hours=$((minutes / 60))
+ days=$((hours / 24))
+ years=$((days / 365))
+
+ if [[ $years -gt 0 ]]; then
+ commit_age="${years}y$((days % 365 ))d"
+ elif [[ $days -gt 0 ]]; then
+ commit_age="${days}d$((hours % 24))h"
+ elif [[ $hours -gt 0 ]]; then
+ commit_age+="${hours}h$(( minutes % 60 ))m"
else
commit_age="${minutes}m"
fi
- color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
- echo "$color$commit_age%{$reset_color%}"
+ echo "${ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL}${commit_age}%{$reset_color%}"
fi
}
-if [[ $USER == "root" ]]; then
- CARETCOLOR="red"
-else
- CARETCOLOR="white"
-fi
-
MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
+# Git prompt settings
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
-
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[green]%}✔%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚ "
@@ -96,6 +69,10 @@ ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
+# Ruby prompt settings
+ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[grey]%}"
+ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
+
# Colors vary depending on time lapsed.
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"