【问题标题】:git browse for Bitbucket repositoriesgit 浏览 Bitbucket 存储库
【发布时间】:2014-07-20 14:00:40
【问题描述】:
我想拥有用于 Bitbucket 存储库的 git browse feature。
在我的工作流程中,我使用 git 在终端中工作,然后我通常会在 Bitbucket 上打开同一个项目以执行拉取请求或查看某些内容,因此我只需要在浏览器中打开工作目录。
假设我使用的是 OS X,我可以使用 open 命令从终端打开一个 url:
$ open http://stackoverflow.com/
【问题讨论】:
标签:
git
shell
terminal
bitbucket
【解决方案1】:
这是我的解决方案,在bash_profile 中添加以下几行:
function git_browse {
if [ "$1" == "browse" ]; then
local domain="$(git ls-remote --get-url | cut -c 5- | cut -d: -f1)"
local url="$(git ls-remote --get-url | cut -c 5- | cut -d: -f2)"
if [ "$domain" == "bitbucket.org" ]; then
open https://bitbucket.org/$url
else
git "$@"
fi
else
git "$@"
fi
}
alias git="git_browse $*"
你如何改进它?