mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-26 02:08:37 +08:00
parent
e52598a5cc
commit
99e2c31484
12
lib/git.zsh
12
lib/git.zsh
|
@ -162,6 +162,18 @@ function git_current_branch() {
|
||||||
echo ${ref#refs/heads/}
|
echo ${ref#refs/heads/}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Outputs the name of the previously checked out branch
|
||||||
|
# Usage example: git pull origin $(git_current_branch)
|
||||||
|
# rev-parse --symbolic-full-name @{-1} only prints if it is a branch
|
||||||
|
function git_previous_branch() {
|
||||||
|
local ref
|
||||||
|
ref=$(__git_prompt_git rev-parse --quiet --symbolic-full-name @{-1} 2> /dev/null)
|
||||||
|
local ret=$?
|
||||||
|
if [[ $ret != 0 ]] || [[ -z $ref ]]; then
|
||||||
|
return # no git repo or non-branch previous ref
|
||||||
|
fi
|
||||||
|
echo ${ref#refs/heads/}
|
||||||
|
}
|
||||||
|
|
||||||
# Gets the number of commits ahead from remote
|
# Gets the number of commits ahead from remote
|
||||||
function git_commits_ahead() {
|
function git_commits_ahead() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user