1
0
mirror of https://github.com/danbee/dotfiles-local synced 2025-03-04 08:49:07 +00:00
dotfiles-local/zsh/configs/prompt.zsh.local

32 lines
823 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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%} '