• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language
    Rust
  • License
    MIT License
  • Created almost 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Command line tool to open repository, file, commit, diff, tag, pull request, blame, issue or project's website in browser for various repository hosting services.

git brws

crates.io Github Actions CI Coverage

git brws is a command line tool to open a repository, file, commit, diff, tag, blame, pull request, issue or project's website in your web browser from command line. 'brws' is an abbreviation of 'browse'.

Features:

Installation

git brws is available on Linux, macOS and Windows.

With Homebrew

$ brew tap "rhysd/git-brws" "https://github.com/rhysd/git-brws"
$ brew install git-brws

It installs git-brws to /usr/local/bin and git-brws.1 to /usr/local/share/man/man1. This is recommended way for installation on macOS since updating to the new version is easy.

On Arch Linux

You can install git-brws via the AUR package:

git clone https://aur.archlinux.org/git-brws.git
cd git-brws
makepkg -si

Download from release page

Pre-built binary executables are available at release page for following targets:

  • Linux 64bit (x86_64-unknown-linux-gnu)
  • macOS 64bit (x86_64-apple-darwin)
  • Windows 64bit (x86_64-pc-windows-msvc)
  • Linux 32bit (i686-unknown-linux-gnu)
  • Windows 32bit (i686-pc-windows-msvc)

Download and unarchive the binary then put the executable in $PATH.

Manpage for man command is available. Please find git-brws.1 in the unarchived directory or download it from here and copy it to the man directory in your system (e.g. /usr/local/share/man/man1/).

Note: git brws --help only works when it is installed. git brws -h is always available.

With cargo

$ cargo install git-brws

It requires Rust toolchain to build git-brws from sources.

Usage

Usage: git brws [Options] {Args}

Options:
    -r, --repo REPO     Shorthand format (repo, user/repo, host/user/repo) or
                        Git URL you want to see. When only repo name is
                        specified, most popular repository will be searched
                        from GitHub
    -b, --branch BRANCH Branch name to browse
    -d, --dir PATH      Directory path to the repository. Default value is
                        current working directory
    -R, --remote REMOTE Remote name (e.g. origin). Default value is a remote
                        the current branch is tracking. If current branch
                        tracks no branch, it falls back to 'origin'
    -u, --url           Output URL to stdout instead of opening in browser
    -p, --pr            Open pull request page instead of repository page. If
                        not existing, open 'Create Pull Request' page
    -w, --website       Open website page instead of repository page (homepage
                        URL for GitHub, GitLab pages, Bitbucket Cloud)
    -B, --blame         Open blame page instead of repository page. File path
                        to blame must be passed also.
    -c, --current-branch
                        Open the current branch instead of default branch
    -h, --help          Print this help
    -v, --version       Show version

Open a repository page

  • Repository at current directory
$ git brws
  • develop branch
$ git brws -b develop
  • origin remote of develop branch
$ git brws -r origin -b develop
  • @rhysd's 'Shiba' repository
$ git brws -r rhysd/Shiba
  • Most popular react repository on GitHub
$ git brws -r react

It will open https://github.com/facebook/react.

Note: When only repository name is specified for -r option, git-brws searches GitHub with query {repo} in:name and opens the best-matched repository page.

  • Specify directory of repository
$ git brws -d ~/.go/src/github.com/rhysd/dot-github

Open a file page

  • File of current branch of current remote
$ git brws ./some/file.txt
  • Line of the file
$ git brws ./some/file.txt#L123

Note: The L can be omit.

  • Range from line to line of the file
$ git brws ./some/file.txt#L123-L126

Note: The L can be omit.

Open a commit page

  • HEAD page of current repository
$ git brws HEAD

Open a tag page

  • 0.10.0 tag page of current repository
$ git brws 0.10.0

Open a diff page between commits

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

Open a diff page from specific commit and its merge base

In addition to .., diff with ... is supported.

  • Diff between branchB and the merge base commit from branchB into branchA
$ git brws branchA...branchB

If you don't know the difference between .. and ..., please read git diff --help.

Note: Only GitHub and GitHub Enterprise support .... For GitLab, only ... is available.

Open a pull request page

  • Pull request page of current branch of current repository
$ git brws --pr
  • Pull request page of specific branch of specific repository
# Specify my forked repository
$ git brws --pr --repo rhysd/rust.vim -b async-contextual-keyword

# Or specify original repository
$ git brws --pr --repo rust-lang/rust.vim -b async-contextual-keyword

Note: Currently only GitHub and GitHub Enterprise are supported.

Note: If you have created multiple pull requests at the same repository with the same branch name, the command may not open a pull request page you want.

Note: When a pull request page for current branch is not existing yet, it opens 'Create Pull Request' page instead.

Open a website for the repository

# Website for current repository
$ git brws --website

With --repo option, arbitrary repository's website can be opened.

# Opens https://reactjs.org
$ git brws --website --repo react

It opens a website for the repository.

  • For GitHub, URL for 'homepage' configuration of the repository if it's set. Otherwise https://{user}.github.io/{repo}
  • For GitHub Enterprise, https://pages.{host}/{user}/{repo} or https://{host}/pages/{user}/{repo} depending on your GitHub Enterprise configuration of subdomain isolation
  • For GitLab, GitLab Pages
  • For Bitbucket, Bitbucket Cloud

Open an issue page

  • Issue #8
$ git brws '#8'

Note: # is usually used for a line comment in major shells. Please quote the argument

Open a blame page

  • Specific file
$ git brws --blame some/file.txt
  • Specific line at file
$ git brws --blame some/file.txt#L5
  • Specific range at file
$ git brws --blame some/file.txt#L5-L9

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

Some environment variables are available to customize behavior of git-brws.

Variable Description
$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 GHE host. If your GHE 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_URL_HOST When you use self-hosted GitLab instance, you can specify its host to this variable. By default, git brws detects host matching to ^gitlab\. as GitLab. If your GitLab URL host does not match it, please specify this variable. If your repository is hosted at https://your-code.net/user/repo, your-code.net should be set.
$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.
$GIT_BRWS_GITHUB_TOKEN This variable is used for --pr (or -p) only. API access token for github.com. They are optional, but useful for avoiding API rate limit and accessing to private repositories. Please generate a token from https://github.com/settings/tokens/new
$GITHUB_TOKEN Ditto. When GIT_BRWS_GITHUB_TOKEN is not set, GITHUB_TOKEN is looked.
$GIT_BRWS_GHE_TOKEN This variable is used for --pr (or -p) only. API access token for GitHub Enterprise instance. It is sometimes mandatory (depending on your GHE instance configuration). Please generate a token from https://{YOUR GHE HOST}/settings/tokens/new.
$GIT_BRWS_BROWSE_COMMAND Command to open URL. If this value is specified, the command is executed with URL as first argument to browse the URL.
$GIT_BRWS_SHORT_COMMIT_HASH Setting true will use 7-letters short commit hash like 78fbce6 for URLs.
$https_proxy This variable is used for --pr (or -p) only. An HTTPS Proxy server URL if you use a web proxy.

Related Projects

TODOs

Please see the project page.

Development

Please see CONTRIBUTING.md.

License

Distributed under the MIT license.

More Repositories

1

vim.wasm

Vim editor ported to WebAssembly
Vim Script
5,305
star
2

actionlint

:octocat: Static checker for GitHub Actions workflow files
Go
2,605
star
3

NyaoVim

Web-enhanced Extensible Neovim Frontend
TypeScript
2,207
star
4

git-messenger.vim

Vim and Neovim plugin to reveal the commit messages under the cursor
Vim Script
1,263
star
5

vim-grammarous

A powerful grammar checker for Vim using LanguageTool.
Vim Script
1,058
star
6

vim-clang-format

Vim plugin for clang-format, a formatter for C, C++, Obj-C, Java, JavaScript, and so on.
Vim Script
1,036
star
7

clever-f.vim

Extended f, F, t and T key mappings for Vim.
Vim Script
968
star
8

Shiba

Rich markdown live preview app with linter
TypeScript
751
star
9

gocaml

🐫 Statically typed functional programming language implementation with Go and LLVM
Go
732
star
10

kiro-editor

A terminal UTF-8 text editor written in Rust 📝🦀
Rust
728
star
11

committia.vim

A Vim plugin for more pleasant editing on commit messages
Vim Script
687
star
12

go-github-selfupdate

Binary self-update mechanism for Go commands using GitHub
Go
527
star
13

conflict-marker.vim

Weapon to fight against conflicts in Vim.
Vim Script
442
star
14

wain

WebAssembly implementation from scratch in Safe Rust with zero dependencies
Rust
425
star
15

hgrep

Grep with human-friendly search results
Rust
419
star
16

electron-about-window

'About This App' mini-window for Electron apps
TypeScript
405
star
17

Mstdn

Tiny web-based mastodon client for your desktop
TypeScript
390
star
18

tui-textarea

Simple yet powerful multi-line text editor widget for ratatui and tui-rs
Rust
287
star
19

vim-color-spring-night

Low-contrast calm color scheme for Vim
Rust
276
star
20

cargo-husky

Setup Git hooks automatically for cargo projects with 🐶
Rust
260
star
21

dot-github

.github directory generator
Go
248
star
22

8cc.vim

C Compiler written in Vim script
Vim Script
227
star
23

vim-startuptime

A small Go program for better `vim --startuptime` alternative
Go
191
star
24

notes-cli

Small markdown note taking CLI app playing nicely with your favorite editor and other CLI tools
Go
191
star
25

dotfiles

dotfiles symbolic links management CLI
Go
191
star
26

neovim-component

<neovim-editor> WebComponent to embed Neovim to your app with great ease
TypeScript
188
star
27

reply.vim

REPLs play nicely with :terminal on Vim and Neovim
Vim Script
183
star
28

monolith-of-web

A chrome extension to make a single static HTML file of the web page using a WebAssembly port of monolith CLI
TypeScript
183
star
29

github-complete.vim

Vim input completion for GitHub
Vim Script
168
star
30

Trendy

Menubar app to keep you in the loop of GitHub trends :octocat:
TypeScript
166
star
31

devdocs.vim

Open devdocs.io from Vim
Vim Script
164
star
32

react-vimjs

Vim in Your Web App
JavaScript
158
star
33

vim-operator-surround

Vim operator mapping to enclose text objects with surrounds like paren, quote and so on.
Vim Script
137
star
34

react-vim-wasm

Vim editor embedded in your React web application
TypeScript
128
star
35

action-setup-vim

GitHub Action to setup Vim or Neovim on Linux, macOS and Windows for testing Vim plugins
TypeScript
126
star
36

accelerated-jk

A vim plugin to accelerate up-down moving!
Vim Script
125
star
37

dogfiles

dog + dotfiles = dogfiles
Vim Script
120
star
38

vim-gfm-syntax

GitHub Flavored Markdown syntax highlight extension for Vim
Vim Script
117
star
39

wandbox-vim

Wandbox plugin for vimmers. http://melpon.org/wandbox/
Vim Script
108
star
40

fixjson

JSON Fixer for Humans using (relaxed) JSON5
TypeScript
99
star
41

tinyjson

Simple JSON parser/generator for Rust
Rust
97
star
42

remark-emoji

Remark markdown transformer to replace :emoji: in text
JavaScript
93
star
43

YourFukurou

Hackable YoruFukurou alternative Twitter client
TypeScript
88
star
44

vim-lsp-ale

Bridge between vim-lsp and ALE
Vim Script
86
star
45

Dachs

Dachs; A Doggy 🐶 Programming Language
C++
81
star
46

vim-textobj-anyblock

A text object for any of '', "", (), {}, [] and <>.
Vim Script
79
star
47

vim-wasm

WebAssembly filetype support for Vim
Vim Script
77
star
48

world-map-gen

🗺️Random world map generator CLI and library for Rust and WebAssembly
Rust
74
star
49

vim-go-impl

A Vim plugin to use `impl` command
Vim Script
72
star
50

rust-doc.vim

Search Rust documents and open with browser from Vim.
Vim Script
71
star
51

ghci-color

colorize ghci output
PowerShell
71
star
52

electron-in-page-search

Module to introduce Electron's native in-page search avoiding pitfalls
TypeScript
66
star
53

translate-markdown

CLI tool to translate Markdown document with Google translate
JavaScript
66
star
54

tweet-app

Desktop Twitter client only for tweeting. Timeline never shows up.
TypeScript
65
star
55

dirname-filename-esm

__dirname and __filename for ES Modules environment
JavaScript
65
star
56

github-clone-all

Clone (~1000) repos matched to query on GitHub using Search API
Go
63
star
57

Tui

Twitter client based on mobile.twitter.com in menu bar
TypeScript
62
star
58

array_view

Wrapper for references to array in C++.
C++
58
star
59

vim-textobj-ruby

Make text objects with various ruby block structures.
Vim Script
56
star
60

fast-json-clone

Clone plain JSON value faster than the fastest
TypeScript
56
star
61

riscv32-cpu-chisel

Learning how to make RISC-V 32bit CPU with Chisel
Scala
55
star
62

changelog-from-release

Simple changelog generator via GitHub releases
Go
54
star
63

vim-llvm

Vim filetype support for LLVM (including official files)
Vim Script
49
star
64

Tilectron

Tiling window browser built on Electron.
JavaScript
45
star
65

nyaovim-markdown-preview

Live Markdown Preview on NyaoVim
HTML
45
star
66

Chromenu

Mobile Chrome in your menubar
TypeScript
43
star
67

Crisp

Lisp dialect implemented with Crystal
Crystal
43
star
68

path-slash

Tiny Rust library to convert a file path from/to slash path
Rust
41
star
69

open-pdf.vim

Convert pdf file to plain text, cache it and open it quickly in vim using pdftotext.
Vim Script
39
star
70

fixred

Fix outdated links in files with redirect URLs
Rust
35
star
71

ghpr-blame.vim

Vim plugin which is like `git-blame`, but for pull requests on GitHub
Vim Script
34
star
72

vim-healthcheck

Polyfill of Neovim's health-check for Vim
Vim Script
33
star
73

nyaovim-mini-browser

Embedded Mini Browser for NyaoVim
HTML
31
star
74

vim-color-splatoon

Vim Splatoon randomized color scheme. Let's play!
Vim Script
29
star
75

vim-fixjson

Vim plugin for fixjson; a JSON fixer for Humans
Vim Script
24
star
76

unite-redpen.vim

A unite.vim integration of redpen for automatic proof reading
Vim Script
24
star
77

vimwasm-try-plugin

Try Vim plugin on your browser without installing it using vim.wasm!
Go
24
star
78

react-component-octicons

Zero-dependency React component for Octicons
TypeScript
24
star
79

go-fakeio

Small Go library to fake stdout/stderr/stdin mainly for unit testing
Go
24
star
80

unite-codic.vim

A unite.vim source for codic-vim.
Vim Script
23
star
81

vim-goyacc

Vim filetype support for goyacc
Vim Script
22
star
82

gofmtrlx

(a bit) relaxed gofmt
Go
22
star
83

try-colorscheme.vim

Try colorscheme on your Vim without installation
Vim Script
21
star
84

node-github-trend

node.js library for scraping GitHub trending repositories.
TypeScript
20
star
85

node-github-emoji

Node.js library for GitHub Emoji :octocat: with TypeScript support
TypeScript
20
star
86

vim-syntax-christmas-tree

Vim filetype plugin for X'mas
Vim Script
20
star
87

toy-riscv-backend

Toy RISC-V LLVM backend
C++
18
star
88

FrozenString

C++ immutable string library in C++11 constexpr and type-level
C++
18
star
89

nyaovim-tree-view

Tree-view sidebar for NyaoVim
JavaScript
18
star
90

vim-github-actions

(Outdated) Vim syntax/indent support for GitHub Actions *.workflow files
Vim Script
18
star
91

zsh-bundle-exec

No longer need to type in 'bundle exec'.
Shell
17
star
92

locerr

❌ locerr (locational error): Library for nice-looking errors in source code
Go
16
star
93

rhysd

README.md for my profile page
Ruby
16
star
94

unite-ruby-require.vim

A unite.vim source for searching gems to require
Vim Script
15
star
95

vim-textobj-conflict

Vim text object plugin to select conflicts
Vim Script
15
star
96

electron-open-url

Open URL with Electron window from command line or Node.js program
JavaScript
15
star
97

vim-notes-cli

Vim plugin for notes-cli
Vim Script
15
star
98

marked-sanitizer-github

A sanitizer for marked.js which sanitizes HTML elements in markdown with the same manner as GitHub
TypeScript
14
star
99

api-dts

d.ts generator from JSON API response
Go
13
star
100

Irasutoyer

Desktop app for Irasutoya lovers
TypeScript
13
star