Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
70c4a27f
Commit
70c4a27f
authored
Jun 04, 2014
by
leif.hanack
Committed by
ncanceill
Jun 10, 2015
Browse files
Added a possibility to display the remote branch and the number of commits you are ahead or behind
parent
41104f8a
Changes
2
Hide whitespace changes
Inline
Side-by-side
lib/git.zsh
View file @
70c4a27f
...
@@ -36,16 +36,26 @@ git_remote_status() {
...
@@ -36,16 +36,26 @@ git_remote_status() {
ahead
=
$(
command
git rev-list
${
hook_com
[branch]
}
@
{
upstream
}
..HEAD 2>/dev/null |
wc
-l
)
ahead
=
$(
command
git rev-list
${
hook_com
[branch]
}
@
{
upstream
}
..HEAD 2>/dev/null |
wc
-l
)
behind
=
$(
command
git rev-list HEAD..
${
hook_com
[branch]
}
@
{
upstream
}
2>/dev/null |
wc
-l
)
behind
=
$(
command
git rev-list HEAD..
${
hook_com
[branch]
}
@
{
upstream
}
2>/dev/null |
wc
-l
)
if
[
$ahead
-
eq
0
]
&&
[
$behind
-
gt
0
]
if
[
$ahead
-
gt
0
]
&&
[
$behind
-
eq
0
]
then
then
echo
"
$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE
"
git_remote_status
=
"
$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE
"
elif
[
$ahead
-gt
0
]
&&
[
$behind
-eq
0
]
git_remote_status_detailed
=
"
$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE
$((
ahead
))
%{
$reset_color
%}"
elif
[
$behind
-gt
0
]
&&
[
$ahead
-eq
0
]
then
then
echo
"
$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE
"
git_remote_status
=
"
$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE
"
git_remote_status_detailed
=
"
$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE
$((
behind
))
%{
$reset_color
%}"
elif
[
$ahead
-gt
0
]
&&
[
$behind
-gt
0
]
elif
[
$ahead
-gt
0
]
&&
[
$behind
-gt
0
]
then
then
echo
"
$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE
"
git_remote_status
=
"
$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE
"
git_remote_status_detailed
=
"
$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE
$((
ahead
))
%{
$reset_color
%}
$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE
$((
behind
))
%{
$reset_color
%}"
fi
fi
if
[
$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED
]
then
git_remote_status
=
"
$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX$remote$git_remote_status_detailed$ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX
"
fi
echo
$git_remote_status
fi
fi
}
}
...
...
themes/strug.zsh-theme
0 → 100644
View file @
70c4a27f
# terminal coloring
export CLICOLOR=1
export LSCOLORS=dxFxCxDxBxegedabagacad
local git_branch='$(git_prompt_info)%{$reset_color%}$(git_remote_status)'
PROMPT="%{$fg[green]%}╭─%n@%m %{$reset_color%}%{$fg[yellow]%}in %~ %{$reset_color%}${git_branch}
%{$fg[green]%}╰\$ %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[yellow]%}on "
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$reset_color%}%{$fg[red]%} ✘ %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[green]%} ✔ %{$reset_color%}"
ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_DETAILED=true
ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_PREFIX="%{$fg[yellow]%}("
ZSH_THEME_GIT_PROMPT_REMOTE_STATUS_SUFFIX="%{$fg[yellow]%})%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=" +"
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE_COLOR=%{$fg[green]%}
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE=" -"
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE_COLOR=%{$fg[red]%}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment