browse: Navigate and Link to Remote Git Files

View source: R/browse.R

browseR Documentation

Navigate and Link to Remote Git Files

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

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

## 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 Sept. 26, 2022, 12:23 p.m.