mirror of
https://github.com/danbee/dotfiles-local
synced 2025-03-04 08:49:07 +00:00
32 lines
823 B
Plaintext
32 lines
823 B
Plaintext
# gets whether git is currently dirty
|
||
git_dirty() {
|
||
git diff --ignore-submodules --quiet
|
||
if [[ $? == 1 ]]; then
|
||
echo "✱"
|
||
else
|
||
git diff --staged --ignore-submodules --quiet
|
||
[[ $? == 1 ]] && echo "✱"
|
||
fi
|
||
}
|
||
|
||
# adds the current branch name in green
|
||
git_prompt_info() {
|
||
ref=$(git symbolic-ref HEAD 2> /dev/null)
|
||
if [[ -n $ref ]]; then
|
||
echo "%{$fg_bold[green]%}${ref#refs/heads/}%{$reset_color%}%{$fg_bold[red]%}$(git_dirty)%{$reset_color%} "
|
||
fi
|
||
}
|
||
|
||
# makes color constants available
|
||
autoload -U colors
|
||
colors
|
||
|
||
# enable colored output from ls, etc
|
||
export CLICOLOR=1
|
||
|
||
# expand functions in the prompt
|
||
setopt promptsubst
|
||
|
||
# prompt
|
||
export PROMPT='$(git_prompt_info)${SSH_CONNECTION+"%{$fg[yellow]%}%n@%m%{$reset_color%}:"}%{$fg_bold[blue]%}%2c%{$reset_color%} %{$fg_bold[cyan]%}❯%{$reset_color%} '
|