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-theme74
1 files changed, 40 insertions, 34 deletions
diff --git a/themes/avit.zsh-theme b/themes/avit.zsh-theme
index a21a9c8c4..87d5be30a 100644
--- a/themes/avit.zsh-theme
+++ b/themes/avit.zsh-theme
@@ -2,16 +2,25 @@
PROMPT='
$(_user_host)${_current_dir} $(git_prompt_info) $(_ruby_version)
-▶ '
+%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} '
-PROMPT2='%{$fg[grey]%}◀%{$reset_color%} '
+PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} '
RPROMPT='$(_vi_status)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
-local _current_dir="%{$fg[blue]%}%3~%{$reset_color%} "
-local _return_status="%{$fg[red]%}%(?..⍉)%{$reset_color%}"
+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%}"
+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
+}
+
function _user_host() {
if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m"
@@ -38,34 +47,32 @@ function _ruby_version() {
# 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() {
- if git rev-parse --git-dir > /dev/null 2>&1; then
- # Only proceed if there is actually a commit.
- if [[ $(git log 2>&1 > /dev/null | grep -c "^fatal: bad default revision") == 0 ]]; then
- # Get the last commit.
- last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
- 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 -gt 24 ]; then
- commit_age="${days}d"
- elif [ $minutes -gt 60 ]; then
- commit_age="${sub_hours}h${sub_minutes}m"
- else
- commit_age="${minutes}m"
- fi
-
- color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
- echo "$color$commit_age%{$reset_color%}"
+# Only proceed if there is actually a commit.
+ if git log -1 > /dev/null 2>&1; then
+ # Get the last commit.
+ last_commit=$(git log --pretty=format:'%at' -1 2> /dev/null)
+ 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 -gt 24 ]; then
+ commit_age="${days}d"
+ elif [ $minutes -gt 60 ]; then
+ commit_age="${sub_hours}h${sub_minutes}m"
+ else
+ commit_age="${minutes}m"
fi
+
+ color=$ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL
+ echo "$color$commit_age%{$reset_color%}"
fi
}
@@ -87,16 +94,15 @@ ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}⚑ "
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖ "
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}▴ "
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}§ "
-ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[grey]%}◒ "
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
# Colors vary depending on time lapsed.
ZSH_THEME_GIT_TIME_SINCE_COMMIT_SHORT="%{$fg[green]%}"
ZSH_THEME_GIT_TIME_SHORT_COMMIT_MEDIUM="%{$fg[yellow]%}"
ZSH_THEME_GIT_TIME_SINCE_COMMIT_LONG="%{$fg[red]%}"
-ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[grey]%}"
+ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}"
# LS colors, made with http://geoff.greer.fm/lscolors/
export LSCOLORS="exfxcxdxbxegedabagacad"
export LS_COLORS='di=34;40:ln=35;40:so=32;40:pi=33;40:ex=31;40:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=0;42:ow=0;43:'
export GREP_COLOR='1;33'
-