Created
June 6, 2019 04:23
-
-
Save gruis/ac1d38f117b3f15194fb1bd9793feead to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/gruis zsh theme | |
# based on blinks and agnoster | |
CURRENT_BG='NONE' | |
case ${SOLARIZED_THEME:-dark} in | |
light) CURRENT_FG='white';; | |
*) CURRENT_FG='black';; | |
esac | |
function _prompt_char() { | |
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then | |
echo "%{%F{blue}%}±%{%f%k%b%}" | |
else | |
echo ' ' | |
fi | |
} | |
# Begin a segment | |
# Takes two arguments, background and foreground. Both can be omitted, | |
# rendering default background/foreground. | |
prompt_segment() { | |
local bg fg | |
[[ -n $1 ]] && bg="%K{$1}" || bg="%k" | |
[[ -n $2 ]] && fg="%F{$2}" || fg="%f" | |
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then | |
echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " | |
else | |
echo -n "%{$bg%}%{$fg%} " | |
fi | |
CURRENT_BG=$1 | |
[[ -n $3 ]] && echo -n $3 | |
} | |
# Git: branch/detached head, dirty status | |
prompt_git() { | |
(( $+commands[git] )) || return | |
if [[ "$(git config --get oh-my-zsh.hide-status 2>/dev/null)" = 1 ]]; then | |
return | |
fi | |
local PL_BRANCH_CHAR | |
() { | |
local LC_ALL="" LC_CTYPE="en_US.UTF-8" | |
PL_BRANCH_CHAR=$'\ue0a0' # | |
} | |
local ref dirty mode repo_path | |
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then | |
repo_path=$(git rev-parse --git-dir 2>/dev/null) | |
dirty=$(parse_git_dirty) | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" | |
if [[ -n $dirty ]]; then | |
prompt_segment yellow black | |
else | |
prompt_segment green $CURRENT_FG | |
fi | |
if [[ -e "${repo_path}/BISECT_LOG" ]]; then | |
mode=" <B>" | |
elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then | |
mode=" >M<" | |
elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then | |
mode=" >R>" | |
fi | |
setopt promptsubst | |
autoload -Uz vcs_info | |
zstyle ':vcs_info:*' enable git | |
zstyle ':vcs_info:*' get-revision true | |
zstyle ':vcs_info:*' check-for-changes true | |
zstyle ':vcs_info:*' stagedstr '✚' | |
zstyle ':vcs_info:*' unstagedstr '●' | |
zstyle ':vcs_info:*' formats ' %u%c' | |
zstyle ':vcs_info:*' actionformats ' %u%c' | |
vcs_info | |
echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" | |
fi | |
} | |
# This theme works with both the "dark" and "light" variants of the | |
# Solarized color schema. Set the SOLARIZED_THEME variable to one of | |
# these two values to choose. If you don't specify, we'll assume you're | |
# using the "dark" variant. | |
case ${SOLARIZED_THEME:-dark} in | |
light) bkg=white;; | |
*) bkg=black;; | |
esac | |
ZSH_THEME_GIT_PROMPT_PREFIX=" [%{%B%F{blue}%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{%f%k%b%K{${bkg}}%B%F{green}%}]" | |
ZSH_THEME_GIT_PROMPT_DIRTY=" %{%F{red}%}*%{%f%k%b%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" | |
PROMPT='%{%f%k%b%} | |
%{%K{black}%B%F{green}%}%n%{%B%F{blue}%}@%{%B%F{cyan}%}%m%{%B%F{green}%} %{%b%F{yellow}%K{black}%}%1/%{%B%F{green}%}%E%{%f%k%b%} %{%K{black}%}$(_prompt_char)%{%K{black}%} %#%{%f%k%b%} ' | |
RPROMPT='$(prompt_git)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment