Created
June 12, 2019 20:35
-
-
Save postazure/d297955169658074d8103028ded53738 to your computer and use it in GitHub Desktop.
oh-my-zsh theme that includes the git authors from git-duet
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
# Save me here -> ~/.oh-my-zsh/themes/pairing.zsh-theme | |
# Git Authors | |
prompt_git_name() { | |
if $(git config --get duet.env.git-author-name >/dev/null 2>&1); then | |
prompt_git_duet_name | |
else | |
prompt_git_normal_name | |
fi | |
} | |
prompt_git_normal_name() { | |
local name=`git config --get user.name` | |
echo "$name" | |
} | |
prompt_git_duet_name() { | |
local author_name=`git config --get duet.env.git-author-initials` | |
local committer_name=`git config --get duet.env.git-committer-initials` | |
local prompt="" | |
[[ $author_name ]] && prompt="$author_name" | |
[[ $committer_name ]] && prompt="$prompt, $committer_name" | |
echo $prompt | |
} | |
# Grab the current filepath, use shortcuts: ~/Desktop | |
# Append the current git branch, if in a git repository | |
JARIN_CURRENT_LOCA_="%{$fg_bold[cyan]%}%~\$(git_prompt_info)%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[white]%} <%{$fg[magenta]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$fg[white]%}" | |
# Do nothing if the branch is clean (no changes). | |
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[white]%}>" | |
# Add a yellow ✗ if the branch is dirty | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[white]%}> %{$fg[yellow]%}✗" | |
precmd(){ | |
PROMPT="[$(prompt_git_name)] $JARIN_CURRENT_LOCA_ " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment