bb is the missing command line interface for Bitbucket.
You can download the latest version of bb
from the downloads page.
Once you get the bb
executable, you can install it anywhere in your $PATH
:
bb
is a modern command line interface. It uses subcommands to perform actions. You can get help on any subcommand by running bb <subcommand> --help
.
General help is also available by running bb --help
or bb help
.
By default bb
works in the current git repository. You can specify a Bitbucket repository with the --repository
flag.
bb
outputs a table by default and get be set per profile. You can also use the --output
flag to change the output format manually. The following formats are supported:
csv
: CSVjson
: JSONyaml
: YAMLtsv
: TSVtable
: Table
For example:
bb --output json workspace list
Or
bb workspace list --output json
bb
uses profiles to store your Bitbucket credentials. You can create a profile with the bb profile create
command:
bb profile create \
--name myprofile \
--client-id <your-client-id> \
--client-secret <your-client-secret>
You can also pass the --default
flag to make this profile the default one, or pass a --output
flag to change the profile output format.
Profiles support the following authentications:
- OAuth 2.0 with the
--client-id
and--client-secret
flags - App passwords with the
--username
and--password
flags. - Repository Access Tokens, Project Access Tokens, Workspace Access Tokens with the
--access-token
flags.
You can get the list of your profiles with the bb profile list
command:
bb profile list
You can get the details of a profile with the bb profile get
or bb profile show
command:
bb profile get myprofile
You can update a profile with the bb profile update
command:
bb profile update myprofile \
--client-id <your-client-id> \
--client-secret <your-client-secret>
You can delete a profile with the bb profile delete
command:
bb profile delete myprofile
You can set the default profile with the bb profile use
command:
bb profile use myprofile
You can list workspaces with the bb workspace list
command:
bb workspace list
With the --membership
flag, you can see the kind of membership you have in each workspace:
bb workspace list --membership
You can also get the details of a workspace with the bb workspace get
or bb workspace show
command:
bb workspace get myworkspace
Additionally, you can get the members of a workspace with the flag --members
:
bb workspace get myworkspace --members
Or, even, a specific member with the flag --member
:
bb workspace get myworkspace --member mymember
You can list projects with the bb project list
command, the --workspace
flag is required for all project commands:
bb project list --workspace myworkspace
The --workspace
flag is also dynamically auto-completed with the workspaces you have access to.
You can also get the details of a project with the bb project get
or bb project show
command:
bb project get myproject --workspace myworkspace
You can create a project with the bb project create
command:
bb project create \
--name myproject \
--key MYPROJECT \
--workspace myworkspace
You can update a project with the bb project update
command:
bb project update myproject \
--name myproject \
--workspace myworkspace
You can delete a project with the bb project delete
command:
bb project delete myproject --workspace myworkspace
You can list pull requests with the bb pullrequest list
command:
bb pullrequest list
You can create a pull request with the bb pullrequest create
command:
bb pullrequest create \
--title "My pull request" \
--source "my-branch" \
--destination "master"
You can get the details of a pull request with the bb pullrequest get
or bb pullrequest show
command:
bb pullrequest get 1
You can approve
or unapprove
a pull request with the bb pullrequest approve
or bb pullrequest unapprove
command:
bb pullrequest approve 1
You can decline
a pull request with the bb pullrequest decline
command:
bb pullrequest decline 1
You can merge
a pull request with the bb pullrequest merge
command:
bb pullrequest merge 1
bb
supports completion for Bash, fish, Powershell, and zsh.
To enable completion, run the following command:
source <(bb completion bash)
You can also add this line to your ~/.bashrc
file to enable completion for every new shell.
bb completion bash > ~/.bashrc
To enable completion, run the following command:
bb completion fish | source
You can also add this line to your ~/.config/fish/config.fish
file to enable completion for every new shell.
bb completion fish > ~/.config/fish/completions/bb.fish
To enable completion, run the following command:
bb completion powershell | Out-String | Invoke-Expression
You can also add the output of the above command to your $PROFILE
file to enable completion for every new shell.
To enable completion, run the following command:
source <(bb completion zsh)
You can also add this line to your functions folder to enable completion for every new shell.
bb completion zsh > "~/${fpath[1]}/_bb"
On macOS, you can add the completion to the brew functions:
bb completion zsh > "$(brew --prefix)/share/zsh/site-functions/_bb"
We will add more commands in the future. If you have any suggestions, please open an issue.
At the moment all outputs are in JSON. We will add more output formats in the future.