Skip to content

Instantly share code, notes, and snippets.

@hharnisc
Created February 20, 2020 02:02
Show Gist options
  • Save hharnisc/b0866c0a465d05789bb66d7674b857c5 to your computer and use it in GitHub Desktop.
Save hharnisc/b0866c0a465d05789bb66d7674b857c5 to your computer and use it in GitHub Desktop.
Minimal ZSH Theme
local resetColor="%{$reset_color%}"
local logo="%{$fg_bold[white]%}Δ$resetColor$resetColor"
local hostname=`hostname`
local dir="%{$fg_bold[white]%}%c$resetColor$resetColor"
GIT_PROMPT_PREFIX="[%{$fg_bold[white]%}"
GIT_PROMPT_SUFFIX="$resetColor]"
GIT_PROMPT_DIRTY="%{$fg_bold[red]%}"
GIT_PROMPT_CLEAN="%{$fg_bold[green]%}"
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg_bold[yellow]%}✚%{$resetColor%}"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg_bold[yellow]%}✹%{$resetColor%}"
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg_bold[yellow]%}✖%{$resetColor%}"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg_bold[yellow]%}➜%{$resetColor%}"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[yellow]%}═%{$resetColor%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[yellow]%}✭%{$resetColor%}"
# modified from https://github.com/robbyrussell/oh-my-zsh/blob/576ada138fc5eed3f58a4aff8141e483310c90fb/lib/git.zsh#L12
function branch_is_dirty() {
local STATUS=''
local -a FLAGS
FLAGS=('--porcelain')
if [[ "$(command git config --get oh-my-zsh.hide-dirty)" != "1" ]]; then
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
FLAGS+='--ignore-submodules=dirty'
fi
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
FLAGS+='--untracked-files=no'
fi
STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1)
fi
if [[ -n $STATUS ]]; then
return 0
else
return 1
fi
}
function git_prompt() {
branch=`git_current_branch`
if [ "$branch" = '' ]; then
# not a git repo
echo ''
else
if branch_is_dirty; then
echo "$GIT_PROMPT_PREFIX$GIT_PROMPT_DIRTY$branch$GIT_PROMPT_SUFFIX"
else
echo "$GIT_PROMPT_PREFIX$GIT_PROMPT_CLEAN$branch$GIT_PROMPT_SUFFIX"
fi
fi
}
function promptLogo() {
print -n "\n$logo "
}
PROMPT='$dir $(git_prompt) $(git_prompt_status) $(promptLogo)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment