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
Dan Barber edbff6109e Initial commit
This should be reasonably close to my original forked thoughtbot
dotfiles configuration. I'm sure there will be some tweaks required!
2015-11-25 18:06:42 +00:00

43 lines
1.1 KiB
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
}
# adds the current ruby version in yellow
ruby_version() {
if (( $+commands[rbenv] )); then
ver=$(rbenv version |cut -d " " -f 1)
if [[ -n $ver ]]; then
echo "%{$fg[red]%}${ver}%{$reset_color%}"
fi
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%} '
export RPROMPT='$(ruby_version)'