browse: Navigate and Link to Remote Git Files

Description Usage Arguments Details Examples

View source: R/browse.R

Description

link creates a permalink to the remote file and copies it to your clipboard for easy sharing. This permalink is based on the HEAD commit of the local git repo.

browse does the same thing, but also opens the website in your default web browser.

Works with Github, Gitlab, and Bitbucket repos.

Usage

1
2
3
browse(path = NULL, remote = "origin")

link(path = NULL, remote = "origin")

Arguments

path

path to the file. The path may be relative to the current working directory, or an absolute path. The default, path = NULL works on a RStudio editor selection.

remote

Name of the remote to link to. Optionally, you can change by setting options(browse.remote.default = "remote_name").

Details

In the path argument, you can optionally include line numbers after the path to the file. See the examples section below. Formatting varies between Github, Gitlab, and Bitbucket.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
# works on an RStudio selection in the editor
browse()
link()

# working directory is the top level of repo
browse("R/browse.R")
link("R/browse.R#L6-L9")

# working directory is the R/ folder of repo
link("../README.md")

# relative or absolute paths to other repos
browse("~/rpackages/dplyr/DESCRIPTION")

## End(Not run)

tmastny/browse documentation built on June 5, 2020, 6:55 a.m.