mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-01-02 02:19:06 +01:00
Merge 0887040c87 into 1120f97305
This commit is contained in:
commit
859e14d044
2 changed files with 30 additions and 6 deletions
30
lib/git.zsh
30
lib/git.zsh
|
|
@ -1,23 +1,41 @@
|
|||
# get the name of the branch we are on
|
||||
function git_prompt_info() {
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null)
|
||||
if [ -z $ref ]; then
|
||||
# check if in detached HEAD mode
|
||||
branch_name=$(git status -sb $(git_submodule_syntax) 2> /dev/null | head -n 1)
|
||||
if [ "$branch_name" = "## HEAD (no branch)" ]; then
|
||||
# set tag name if found
|
||||
tag_name=$(git name-rev --name-only $(git --no-pager show --stat 2> /dev/null | head -n 1 | awk '{ print $2 }') 2> /dev/null)
|
||||
if [ -z $tag_name ]; then
|
||||
ref="detached HEAD"
|
||||
else
|
||||
ref=$tag_name
|
||||
fi
|
||||
else
|
||||
return
|
||||
fi
|
||||
fi
|
||||
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
|
||||
}
|
||||
|
||||
|
||||
# Checks if working tree is dirty
|
||||
parse_git_dirty() {
|
||||
local SUBMODULE_SYNTAX=''
|
||||
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
|
||||
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
|
||||
fi
|
||||
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
|
||||
if [[ -n $(git status -s $(git_submodule_syntax) 2> /dev/null) ]]; then
|
||||
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
|
||||
else
|
||||
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
|
||||
fi
|
||||
}
|
||||
|
||||
git_submodule_syntax() {
|
||||
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
|
||||
echo "--ignore-submodules=dirty"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
# Checks if there are commits ahead from remote
|
||||
function git_prompt_ahead() {
|
||||
|
|
|
|||
6
themes/hybrid.zsh-theme
Normal file
6
themes/hybrid.zsh-theme
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Theme with full path names and hostname
|
||||
# Handy if you work on different servers all the time;
|
||||
PROMPT='%{$fg[cyan]%}%n%{$reset_color%}@%{$fg[yellow]%}%M:%{$fg[green]%}${PWD/#$HOME/~}%{$reset_color%} %{$fg[red]%}rb:($(rbenv_prompt_info))%{$reset_color%}$(git_prompt_info) %(!.#.$) '
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[cyan]%}git:("
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue