+
Skip to content

[bash completion] allow display of the name of the remote the current branch is tracking #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@
# per-repository basis by setting the bash.showUpstream config
# variable.
#
# If you would like to see the name of the remote that the current branch
# is tracking, set GIT_PS1_SHOWBRANCHREMOTE to a nonempty value. If the
# current branch is tracking a remote branch, the name of that remote is
# displayed before the branch name, separated by a colon.
#
#
# To submit patches:
#
Expand Down Expand Up @@ -217,7 +222,6 @@ __git_ps1_show_upstream ()
p=" u+${count#* }-${count% *}" ;;
esac
fi

}


Expand Down Expand Up @@ -278,6 +282,8 @@ __git_ps1 ()
local u=""
local c=""
local p=""
local remote=""
local branch=""

if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
Expand Down Expand Up @@ -309,10 +315,17 @@ __git_ps1 ()
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
__git_ps1_show_upstream
fi
branch=${b##refs/heads/}
if [ -n "${GIT_PS1_SHOWBRANCHREMOTE-}" ]; then
remote=`git config --get branch.$branch.remote`
if [[ $remote ]]; then
remote=$remote:
fi
fi
fi

local f="$w$i$s$u"
printf "${1:- (%s)}" "$c${b##refs/heads/}${f:+ $f}$r$p"
printf "${1:- (%s)}" "$c$remote$branch${f:+ $f}$r$p"
fi
}

Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载