Skip to content

Instantly share code, notes, and snippets.

@lajlev
Last active February 14, 2017 08:15
Show Gist options
  • Save lajlev/61e7dc38fedd062159558074c65bd0ab to your computer and use it in GitHub Desktop.
Save lajlev/61e7dc38fedd062159558074c65bd0ab to your computer and use it in GitHub Desktop.
Bitbucket bash commands
function bbcreate(){
curl -s -S -X POST -v -u lajlev:$BITBUCKET_PASS -H "Content-Type: application/json" \
https://api.bitbucket.org/2.0/repositories/lajlev/$1 \
-d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }' > /dev/null
printf "\n 🍄 https://bitbucket.org/lajlev/$1 created\n\n"
}
function bbdelete(){
read -r -p "Delete https://bitbucket.org/lajlev/$1 ? [y/N] " response
response=${response,,}
if [[ "$response" =~ ^(yes|y)$ ]]
then
curl -s -S -X DELETE -u lajlev:$BITBUCKET_PASS https://api.bitbucket.org/2.0/repositories/lajlev/$1 > /dev/null
printf "\n 💀 $1 deleted\n\n"
else
exit 0
fi
}
function bbinit(){
git init
curl -X POST -v -u lajlev:$BITBUCKET_PASS -H "Content-Type: application/json" \
https://api.bitbucket.org/2.0/repositories/lajlev/$1 \
-d '{"scm": "git", "is_private": "true", "fork_policy": "no_public_forks" }'
git remote add origin git@bitbucket.org:lajlev/$1.git
git add .
git commit -m "init"
git push --set-upstream origin master
printf "\n📦 git init\n🍄 https://bitbucket.org/lajlev/$1 created\n🚀 Pushed\n\n"
}
function bitbucket() {
giturl=$(git config --get remote.origin.url)
if [ "$giturl" == "" ]
then
echo "Not a git repository or no remote.origin.url set"
exit 1;
fi
giturl=${giturl/git\@bitbucket\.org\:/https://bitbucket.org/}
giturl=${giturl/\.git/\/src}
giturl=${giturl/git@/http://}
open $giturl
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment