xopen

Open System Files, URLs, Anything

R-CMD-check CRAN RStudio mirror downloads Codecov test coverage

Cross platform solution to open files, directories or URLs with their associated programs. Inspired by shell.exec(), https://github.com/pwnall/node-open and https://github.com/sindresorhus/opn

Installation

Stable version:

install.packages("xopen")

Development version:

pak::pak("r-lib/xopen")

Usage

library(xopen)

Open a file:

xopen("test.R")

Open a URL:

xopen("https://ps.r-lib.org")

URL with given app:

chrome <- function() {
  switch(
    get_os(),
    win = "Chrome",
    macos = "google chrome",
    other = "google-chrome")
}
xopen("https://processx.r-lib.org", app = chrome())

Open a given app (or switch to it, if already open):

xopen(app = chrome())

App and arguments. (You need to quit Chrome for this to work):

xopen(app = c(chrome(), "--incognito", "https://github.com"))

License

MIT © RStudio