Skip to content

Instantly share code, notes, and snippets.

@davidbarral davidbarral/bitbucket.zsh

Last active Dec 23, 2015
Embed
What would you like to do?
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
You can’t perform that action at this time.