Skip to content

Instantly share code, notes, and snippets.

@davidbarral
Last active December 23, 2015 19:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidbarral/6683804 to your computer and use it in GitHub Desktop.
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.
# 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