mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-30 02:44:42 +01:00
stibbons is a clean, one-lined, git-optimized prompt
Signed-off-by: Gaetan Semet <gaetan@xeberon.net>
This commit is contained in:
parent
86a889ea08
commit
3c63e773a2
2 changed files with 44 additions and 0 deletions
19
lib/git.zsh
19
lib/git.zsh
|
|
@ -114,6 +114,25 @@ git_prompt_status() {
|
|||
echo $STATUS
|
||||
}
|
||||
|
||||
# Checks if there is a bisect, merge or rebase currently going on
|
||||
git_prompt_rebase_state() {
|
||||
STATUS=""
|
||||
|
||||
if [ -f ".git/BISECT_LOG" ] ; then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_STATE_BEFORE$ZSH_THEME_GIT_PROMPT_STATE_BISECT"
|
||||
elif [ -f ".git/MERGE_HEAD" ] ; then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_STATE_BEFORE$ZSH_THEME_GIT_PROMPT_STATE_MERGE"
|
||||
else
|
||||
for dir in rebase rebase-apply rebase-merge ; do
|
||||
if [ -d ".git/$dir" ] ; then
|
||||
STATUS="$ZSH_THEME_GIT_PROMPT_STATE_BEFORE$ZSH_THEME_GIT_PROMPT_STATE_REBASE"
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
echo $STATUS
|
||||
}
|
||||
|
||||
#compare the provided version of git to the version installed and on path
|
||||
#prints 1 if input version <= installed version
|
||||
#prints -1 otherwise
|
||||
|
|
|
|||
25
themes/stibbons.zsh-theme
Normal file
25
themes/stibbons.zsh-theme
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||
|
||||
#Customized git status, oh-my-zsh currently does not allow render dirty status before branch
|
||||
git_custom_status() {
|
||||
local cb=$(current_branch)
|
||||
if [ -n "$cb" ]; then
|
||||
echo "$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_PREFIX$(current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX$(git_prompt_rebase_state)"
|
||||
fi
|
||||
}
|
||||
|
||||
#RVM and git settings
|
||||
if [[ -s ~/.rvm/scripts/rvm ]] ; then
|
||||
RPS1='$(git_custom_status)%{$fg[red]%}[`~/.rvm/bin/rvm-prompt`]%{$reset_color%} $EPS1'
|
||||
else
|
||||
if which rbenv &> /dev/null; then
|
||||
RPS1='$(git_custom_status)%{$fg[red]%}[`rbenv version | sed -e "s/ (set.*$//"`]%{$reset_color%} $EPS1'
|
||||
else
|
||||
RPS1='$(git_custom_status) $EPS1'
|
||||
fi
|
||||
fi
|
||||
|
||||
PROMPT='%{$fg[cyan]%}[%{$fg[yellow]%}%n%{$fg[cyan]%}@%{$fg[yellow]%}%m%{$fg[cyan]%}:%{$fg[magenta]%}%~% %{$fg[cyan]%}]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '
|
||||
Loading…
Add table
Add a link
Reference in a new issue