Skip to content

Instantly share code, notes, and snippets.

@drinchev
Created September 28, 2023 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drinchev/7bd39a47fdcfbaf12e52dde898d894af to your computer and use it in GitHub Desktop.
Save drinchev/7bd39a47fdcfbaf12e52dde898d894af to your computer and use it in GitHub Desktop.
Theme for zsh
# Git: branch/detached head, dirty status
prompt_git() {
local ref dirty mode repo_path
repo_path=$(git rev-parse --git-dir 2>/dev/null)
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
# if [[ -n $dirty ]]; then
# prompt_segment yellow black
# else
# prompt_segment green black
# 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:git:*' unstagedstr '●'
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
# vcs_info
# echo -n "${ref/refs\/heads\//}"
if [[ -n $dirty ]]; then
echo -en " %{$fg[yellow]%}⚑%{$reset_color%}"
else
echo -en " %{$fg[green]%}⚑%{$reset_color%}"
fi
fi
}
PROMPT='%{$fg[blue]%}λ%{$reset_color%} %{$FG[008]%}%~%{$reset_color%} %{$FG[011]%}·%{$reset_color%} '
# RPROMPT='$(git_prompt_info)%{$reset_color%}'
RPROMPT='$(prompt_git)'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment