Last active
December 23, 2015 19:39
-
-
Save davidbarral/6683804 to your computer and use it in GitHub Desktop.
Function + Aliases to quick open severla Bitbuket pages related to the current Git project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE: | |
# | |
# Inside a bitbucket repo (remote must be origin) call: | |
# | |
# bb -> Go to overview page | |
# bbs <branch> -> Go to branch source. Defaults to master | |
# bbc <commit> -> Go to commit diff. Defaults to HEAD | |
# bbp -> Go to pull requests page | |
# bbnp -> New pull reques form | |
# | |
function _open_bb_page { | |
local url | |
local -a parts | |
base_url="https://$(git remote -v | grep fetch | grep origin | cut -d@ -f2 | cut -d\ -f1 | sed -e 's/:/\//')" | |
parts=($base_url $@) | |
url=${(j:/:)parts} | |
echo "Opening $url" | |
open $url | |
} | |
alias bb="_open_bb_page" | |
alias bbs="_open_bb_page 'src'" | |
alias bbc="_open_bb_page 'commits'" | |
alias bbp="_open_bb_page 'pull-requests'" | |
alias bbnp="_open_bb_page 'pull-request/new'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment