mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-18 20:00:07 +00:00
avit: clean up theme code
This commit is contained in:
parent
443ad88024
commit
77813a330b
1 changed files with 17 additions and 34 deletions
|
@ -1,27 +1,20 @@
|
|||
# AVIT ZSH Theme
|
||||
|
||||
# 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%}"
|
||||
|
||||
PROMPT='
|
||||
$(_user_host)${_current_dir} $(git_prompt_info) $(ruby_prompt_info)
|
||||
%{$fg[$CARETCOLOR]%}▶%{$resetcolor%} '
|
||||
%{%F{%(!.red.white)}%}▶%{$resetcolor%} '
|
||||
|
||||
PROMPT2='%{$fg[$CARETCOLOR]%}◀%{$reset_color%} '
|
||||
PROMPT2='%{%F{%(!.red.white)}%}◀%{$reset_color%} '
|
||||
|
||||
RPROMPT='$(vi_mode_prompt_info)%{$(echotc UP 1)%}$(_git_time_since_commit) $(git_prompt_status) ${_return_status}%{$(echotc DO 1)%}'
|
||||
|
||||
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() {
|
||||
local me
|
||||
if [[ -n $SSH_CONNECTION ]]; then
|
||||
me="%n@%m"
|
||||
elif [[ $LOGNAME != $USER ]]; then
|
||||
|
@ -35,39 +28,29 @@ function _user_host() {
|
|||
# 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 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))
|
||||
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"
|
||||
if [[ $hours -ge 24 ]]; then
|
||||
commit_age="$(( hours / 24 ))d"
|
||||
elif [[ $hours -gt 0 ]]; then
|
||||
commit_age+="$(( hours % 24 ))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
|
||||
|
|
Loading…
Reference in a new issue