Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
a482a029
Unverified
Commit
a482a029
authored
Nov 14, 2022
by
Lennart Ochel
Committed by
GitHub
Nov 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(git-prompt): add option to show upstream branch (#11336)
parent
b70977b2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
README.md
plugins/git-prompt/README.md
+2
-0
git-prompt.plugin.zsh
plugins/git-prompt/git-prompt.plugin.zsh
+8
-1
No files found.
plugins/git-prompt/README.md
View file @
a482a029
...
...
@@ -45,6 +45,7 @@ The symbols are as follows:
| ●n | there are
`n`
staged files |
| ✖n | there are
`n`
unmerged files |
| ✚n | there are
`n`
unstaged files |
| -n | there are
`n`
deleted files |
| ⚑n | there are
`n`
stashed changes |
| … | there are some untracked files |
...
...
@@ -59,6 +60,7 @@ The symbols are as follows:
## Customisation
-
Set the variable
`ZSH_THEME_GIT_PROMPT_CACHE`
to any value in order to enable caching.
-
Set the variable
`ZSH_THEME_GIT_SHOW_UPSTREAM`
to any value to display the upstream branch.
-
You may also change a number of variables (whose name start with
`ZSH_THEME_GIT_PROMPT_`
)
to change the appearance of the prompt. Take a look at the bottom of the
[
plugin file
](
git-prompt.plugin.zsh
)
`
to see what variables are available.
...
...
plugins/git-prompt/git-prompt.plugin.zsh
View file @
a482a029
...
...
@@ -48,12 +48,18 @@ function update_current_git_vars() {
GIT_STASHED
=
$__CURRENT_GIT_STATUS
[
8]
GIT_CLEAN
=
$__CURRENT_GIT_STATUS
[
9]
GIT_DELETED
=
$__CURRENT_GIT_STATUS
[
10]
if
[
-z
${
ZSH_THEME_GIT_SHOW_UPSTREAM
+x
}
]
;
then
GIT_UPSTREAM
=
else
GIT_UPSTREAM
=
$(
git rev-parse
--abbrev-ref
--symbolic-full-name
"@{upstream}"
2>/dev/null
)
&&
GIT_UPSTREAM
=
"
${
ZSH_THEME_GIT_PROMPT_UPSTREAM_SEPARATOR
}${
GIT_UPSTREAM
}
"
fi
}
git_super_status
()
{
precmd_update_git_vars
if
[
-n
"
$__CURRENT_GIT_STATUS
"
]
;
then
STATUS
=
"
$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH
%{
${
reset_color
}
%}"
STATUS
=
"
$ZSH_THEME_GIT_PROMPT_PREFIX$ZSH_THEME_GIT_PROMPT_BRANCH$GIT_BRANCH
$GIT_UPSTREAM
%{
${
reset_color
}
%}"
if
[
"
$GIT_BEHIND
"
-ne
"0"
]
;
then
STATUS
=
"
$STATUS$ZSH_THEME_GIT_PROMPT_BEHIND$GIT_BEHIND
%{
${
reset_color
}
%}"
fi
...
...
@@ -101,6 +107,7 @@ ZSH_THEME_GIT_PROMPT_AHEAD="%{↑%G%}"
ZSH_THEME_GIT_PROMPT_UNTRACKED
=
"%{
$fg
[cyan]%}%{…%G%}"
ZSH_THEME_GIT_PROMPT_STASHED
=
"%{
$fg_bold
[blue]%}%{⚑%G%}"
ZSH_THEME_GIT_PROMPT_CLEAN
=
"%{
$fg_bold
[green]%}%{✔%G%}"
ZSH_THEME_GIT_PROMPT_UPSTREAM_SEPARATOR
=
"->"
# Set the prompt.
RPROMPT
=
'$(git_super_status)'
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