2011-11-06 13:07:16 +01:00
|
|
|
|
# AVIT ZSH Theme
|
|
|
|
|
|
2020-02-19 17:24:20 +01:00
|
|
|
|
# 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%}"
|
|
|
|
|
|
2011-11-06 13:07:16 +01:00
|
|
|
|
PROMPT='
|
2020-02-19 16:53:10 +01:00
|
|
|
|
$(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
|
2020-09-26 12:15:59 +02:00
|
|
|
|
%{%(!.${fg[red]}.${fg[white]})%}▶%{$reset_color%} '
|
2011-11-06 13:07:16 +01:00
|
|
|
|
|
2020-09-26 12:15:59 +02:00
|
|
|
|
PROMPT2='%{%(!.${fg[red]}.${fg[white]})%}◀%{$reset_color%} '
|
2011-11-06 13:07:16 +01:00
|
|
|
|
|
2023-10-14 00:26:16 +02:00
|
|
|
|
__RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
|
|
|
|
|
if [[ -z $RPROMPT ]]; then
|
|
|
|
|
RPROMPT=$__RPROMPT
|
|
|
|
|
else
|
|
|
|
|
RPROMPT="${RPROMPT} ${__RPROMPT}"
|
|
|
|
|
fi
|
2011-11-06 13:07:16 +01:00
|
|
|
|
|
|
|
|
|
function _user_host() {
|
2020-02-19 17:24:20 +01:00
|
|
|
|
local me
|
2011-11-06 13:07:16 +01:00
|
|
|
|
if [[ -n $SSH_CONNECTION ]]; then
|
|
|
|
|
me="%n@%m"
|
2021-03-25 12:08:00 +01:00
|
|
|
|
elif [[ $LOGNAME != $USERNAME ]]; then
|
2011-11-06 13:07:16 +01:00
|
|
|
|
me="%n"
|
|
|
|
|
fi
|
|
|
|
|
if [[ -n $me ]]; then
|
|
|
|
|
echo "%{$fg[cyan]%}$me%{$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() {
|
2020-02-19 17:24:20 +01:00
|
|
|
|
local last_commit now seconds_since_last_commit
|
2020-02-19 18:19:46 +01:00
|
|
|
|
local minutes hours days years commit_age
|
2020-02-19 17:24:20 +01:00
|
|
|
|
# Only proceed if there is actually a commit.
|
2022-01-10 19:39:05 +01:00
|
|
|
|
if last_commit=$(command git -c log.showSignature=false log --format='%at' -1 2>/dev/null); then
|
2014-07-02 19:22:32 +02:00
|
|
|
|
now=$(date +%s)
|
|
|
|
|
seconds_since_last_commit=$((now-last_commit))
|
|
|
|
|
|
|
|
|
|
# Totals
|
|
|
|
|
minutes=$((seconds_since_last_commit / 60))
|
2020-02-19 18:19:46 +01:00
|
|
|
|
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"
|
2020-02-19 17:24:20 +01:00
|
|
|
|
elif [[ $hours -gt 0 ]]; then
|
2020-02-19 18:19:46 +01:00
|
|
|
|
commit_age+="${hours}h$(( minutes % 60 ))m"
|
2014-07-02 19:22:32 +02:00
|
|
|
|
else
|
|
|
|
|
commit_age="${minutes}m"
|
2011-11-06 13:07:16 +01:00
|
|
|
|
fi
|
2014-07-02 19:22:32 +02:00
|
|
|
|
|
2020-02-19 17:24:20 +01:00
|
|
|
|
echo "${ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL}${commit_age}%{$reset_color%}"
|
2011-11-06 13:07:16 +01:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MODE_INDICATOR="%{$fg_bold[yellow]%}❮%{$reset_color%}%{$fg[yellow]%}❮❮%{$reset_color%}"
|
|
|
|
|
|
2020-02-19 16:53:10 +01:00
|
|
|
|
# Git prompt settings
|
2011-11-06 13:07:16 +01:00
|
|
|
|
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]%}✚ "
|
|
|
|
|
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]%}§ "
|
2015-07-27 12:03:50 +02:00
|
|
|
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}◒ "
|
2011-11-06 13:07:16 +01:00
|
|
|
|
|
2020-02-19 16:53:10 +01:00
|
|
|
|
# Ruby prompt settings
|
|
|
|
|
ZSH_THEME_RUBY_PROMPT_PREFIX="%{$fg[grey]%}"
|
|
|
|
|
ZSH_THEME_RUBY_PROMPT_SUFFIX="%{$reset_color%}"
|
|
|
|
|
|
2011-11-06 13:07:16 +01:00
|
|
|
|
# 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]%}"
|
2015-07-27 12:03:50 +02:00
|
|
|
|
ZSH_THEME_GIT_TIME_SINCE_COMMIT_NEUTRAL="%{$fg[white]%}"
|
2011-11-06 13:07:16 +01:00
|
|
|
|
|
2018-08-07 20:42:02 +02:00
|
|
|
|
# LS colors, made with https://geoff.greer.fm/lscolors/
|
2011-11-06 13:07:16 +01:00
|
|
|
|
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:'
|
2022-11-23 18:56:26 +01:00
|
|
|
|
export GREP_COLORS='mt=1;33'
|