Command line tool to browse a page for repository, file, commit or diff.
Rust
Permalink
Failed to load latest commit information.
src rename GitHub Enterprise related environment variables (v0.6.0) Jan 15, 2017
.gitignore normalize --repo format Dec 25, 2016
.travis.yml run tests in serial because of environment variables Jan 15, 2017
Cargo.lock
Cargo.toml rename GitHub Enterprise related environment variables (v0.6.0) Jan 15, 2017
LICENSE.txt prepare license and Guardfile Dec 24, 2016
README.md

README.md

git brws

Crate Badge Build Status

git brws is a command line tool to open a repository, file, commit or diff in your web browser from command line.

Features:

Installation

git brws currently supports Linux (x86_64, i686, aarch64) and macOS.

$ cargo install git-brws
  • As single binary

You can download a binary executable from release page. Unarchive downloaded file and put the binary in your bin directory.

Usage

Usage: git brws [Options] {Args}

Options:
    -r, --repo REPO     Shorthand format (user/repo, service/user/repo) or
                        remote name (e.g. origin) or Git URL you want to see
    -b, --branch BRANCH Branch name of the repository
    -d, --dir PATH      Directory path to your repository
    -u, --url           Output URL to STDOUT instead of opening in browser
    -h, --help          Print this help
    -v, --version       Show version

Usage Examples

Open a repository page

  • Open current repository page
$ git brws
  • Open 'develop' branch
$ git brws -b develop
  • Open 'origin' remote of 'develop' branch
$ git brws -r origin -b develop
  • Open @rhysd's 'Shiba' repository
$ git brws -r rhysd/Shiba
  • Open a repository specified by directory
$ git brws -d ~/.go/src/github.com/rhysd/dot-github

Open specific file

  • Open specific file of current branch of current remote
$ git brws ./some/file.txt
  • Open specific line of the file
$ git brws ./some/file.txt#L123

Open a specific commit page

  • Open HEAD page of current repository
$ git brws HEAD

Show a specific diff page

  • Show diff between HEAD and HEAD~3
$ git brws HEAD~3..HEAD
  • Show diff between 113079b and 60024ab
$ git brws 60024ab..113079b

Cooperate with other tools

With -u option, git brws outputs URL to stdout.

For example, in Vim, you can write your repository URL to your text instantly.

:r!git brws -u

And below can open editing file in your browser.

:!git brws %

Customization

You can customize behavior of this command with environment varibles.

  • $GIT_BRWS_GIT_COMMAND: Git command to use. If not specified, "git" will be used.
  • $GIT_BRWS_GHE_URL_HOST: When you use your own GitHub:Enterprise repository, you can specify its host to this variable. By default, git brws detects ^github\. as GH:E host. If your GH:E repository host does not match it, please specify this variable. If your repository is https://example-repo.org/user/repo, example-repo.org should be set.
  • GIT_BRWS_GHE_SSH_PORT: When you set a number to it, the number will be used for the ssh port for GITHUB:Enterprise URLs.
  • GIT_BRWS_GITLAB_SSH_PORT: When you set a number to it, the number will be used for the ssh port for self-hosted GitLab URLs. This is useful when your environment hosts GitLab to non-trivial ssh port URL.

Related Projects

License

Distributed under the MIT license.

TODOs

Please see the project page.

Development

cargo install cargo-watch
# Watch and build sources/tests automatically
cargo watch