Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Ohmyzsh
Commits
77813a33
Commit
77813a33
authored
Feb 19, 2020
by
Marc Cornellà
Browse files
avit: clean up theme code
parent
443ad880
Changes
1
Show whitespace changes
Inline
Side-by-side
themes/avit.zsh-theme
View file @
77813a33
# 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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment