mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-01 04:30:37 +02:00
Add bira-squared theme
Signed-off-by: Bryan Stone <bstone@datapipe.com>
This commit is contained in:
parent
31a84e710f
commit
da04c0abd5
1 changed files with 129 additions and 0 deletions
129
themes/bira-squared.zsh-theme
Normal file
129
themes/bira-squared.zsh-theme
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
|
||||||
|
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
|
||||||
|
|
||||||
|
if [[ $UID -eq 0 ]]; then
|
||||||
|
local user_host='%{$terminfo[bold]$fg[red]%}%n%{$fg_bold[yellow]%}@%m%{$reset_color%}'
|
||||||
|
else
|
||||||
|
local user_host='%{$terminfo[bold]$fg[green]%}%n%{$fg_bold[yellow]%}@%m%{$reset_color%}'
|
||||||
|
fi
|
||||||
|
|
||||||
|
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
|
||||||
|
|
||||||
|
ZSH_THEME_GIT_PROMPT_PREFIX="[%{$fg_bold[green]%}±%{$reset_color%}%{$fg_bold[white]%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}]"
|
||||||
|
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✓%{$reset_color%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg[cyan]%}▴%{$reset_color%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_BEHIND="%{$fg[magenta]%}▾%{$reset_color%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●%{$reset_color%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[yellow]%}●%{$reset_color%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[red]%}●%{$reset_color%}"
|
||||||
|
|
||||||
|
custom_rvm_ruby () {
|
||||||
|
if which rvm-prompt &> /dev/null; then
|
||||||
|
_rvm_ver="$(rvm-prompt i v)"
|
||||||
|
if [ -n "$_rvm_ver" ]; then
|
||||||
|
_rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v)$fg[magenta]%}$(rvm-prompt g)%{$fg[red]%}›%{$reset_color%} '
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if which rbenv &> /dev/null; then
|
||||||
|
_rvm_ver='$(rbenv version | sed -e "s/ (set.*$//")'
|
||||||
|
if [[ "${_rvm_ver}x" != "x" ]]; then
|
||||||
|
_rvm_ruby='%{$fg[red]%}‹$_rvm_ver›%{$reset_color%} '
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "${_rvm_ruby}"
|
||||||
|
}
|
||||||
|
|
||||||
|
custom_git_branch () {
|
||||||
|
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
|
||||||
|
ref=$(command git rev-parse --short HEAD 2> /dev/null) || return
|
||||||
|
echo "${ref#refs/heads/}"
|
||||||
|
}
|
||||||
|
|
||||||
|
custom_git_status() {
|
||||||
|
_STATUS=""
|
||||||
|
|
||||||
|
# check status of files
|
||||||
|
_INDEX=$(command git status --porcelain 2> /dev/null)
|
||||||
|
if [[ -n "$_INDEX" ]]; then
|
||||||
|
if $(echo "$_INDEX" | command grep -q '^[AMRD]. '); then
|
||||||
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
|
||||||
|
fi
|
||||||
|
if $(echo "$_INDEX" | command grep -q '^.[MTD] '); then
|
||||||
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
|
||||||
|
fi
|
||||||
|
if $(echo "$_INDEX" | command grep -q -E '^\?\? '); then
|
||||||
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
|
||||||
|
fi
|
||||||
|
if $(echo "$_INDEX" | command grep -q '^UU '); then
|
||||||
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check status of local repository
|
||||||
|
_INDEX=$(command git status --porcelain -b 2> /dev/null)
|
||||||
|
if $(echo "$_INDEX" | command grep -q '^## .*ahead'); then
|
||||||
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
|
||||||
|
fi
|
||||||
|
if $(echo "$_INDEX" | command grep -q '^## .*behind'); then
|
||||||
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_BEHIND"
|
||||||
|
fi
|
||||||
|
if $(echo "$_INDEX" | command grep -q '^## .*diverged'); then
|
||||||
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_DIVERGED"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $(command git rev-parse --verify refs/stash &> /dev/null); then
|
||||||
|
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_STASHED"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $_STATUS
|
||||||
|
}
|
||||||
|
|
||||||
|
custom_git_prompt () {
|
||||||
|
local _branch=$(custom_git_branch)
|
||||||
|
local _status=$(custom_git_status)
|
||||||
|
local _result=""
|
||||||
|
if [[ "${_branch}x" != "x" ]]; then
|
||||||
|
_result="$ZSH_THEME_GIT_PROMPT_PREFIX$_branch"
|
||||||
|
if [[ "${_status}x" != "x" ]]; then
|
||||||
|
_result="$_result $_status"
|
||||||
|
fi
|
||||||
|
_result="$_result$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||||
|
fi
|
||||||
|
echo $_result
|
||||||
|
}
|
||||||
|
|
||||||
|
get_space () {
|
||||||
|
local STR=$1$2
|
||||||
|
local zero='%([BSUbfksu]|([FB]|){*})'
|
||||||
|
local LENGTH=${#${(S%%)STR//$~zero/}}
|
||||||
|
local SPACES=""
|
||||||
|
(( LENGTH = ${COLUMNS} - $LENGTH - 1))
|
||||||
|
|
||||||
|
for i in {0..$LENGTH}
|
||||||
|
do
|
||||||
|
SPACES="$SPACES "
|
||||||
|
done
|
||||||
|
|
||||||
|
echo $SPACES
|
||||||
|
}
|
||||||
|
|
||||||
|
_1LEFT="╭─${user_host} ${current_dir}"
|
||||||
|
|
||||||
|
custom_precmd () {
|
||||||
|
_1RIGHT="%{$fg[$NCOLOR]%}%p $(custom_rvm_ruby)$(custom_git_prompt)%{$reset_color%}"
|
||||||
|
_1SPACES=`get_space $_1LEFT $_1RIGHT`
|
||||||
|
print
|
||||||
|
print -rP "$_1LEFT$_1SPACES$_1RIGHT"
|
||||||
|
}
|
||||||
|
|
||||||
|
setopt prompt_subst
|
||||||
|
PROMPT="╰─%{$fg[yellow]%}⚡%{$reset_color%} "
|
||||||
|
PS2=" %{$fg[yellow]%}⚡%{$reset_color%} "
|
||||||
|
RPROMPT='${return_code}'
|
||||||
|
|
||||||
|
autoload -U add-zsh-hook
|
||||||
|
add-zsh-hook precmd custom_precmd
|
||||||
Loading…
Add table
Add a link
Reference in a new issue