R/sublimetext.R

Defines functions open_sublime_text open_finder open_iterm

open_sublime_text <- function() {
    active_path <- rstudioapi::getActiveDocumentContext()$path
    if (is.null(active_path) || !nzchar(active_path)) {
        active_path <- rstudioapi::getActiveProject()
    }
    system2("subl", shQuote(active_path))
}


open_finder <- function() {
    active_path <- rstudioapi::getActiveDocumentContext()$path
    if (is.null(active_path) || !nzchar(active_path)) {
        dir <- rstudioapi::getActiveProject()
    } else {
        dir <- dirname(active_path)
    }
    system2("open", shQuote(dir))
}

open_iterm <- function() {
    active_path <- rstudioapi::getActiveDocumentContext()$path
    if (is.null(active_path) || !nzchar(active_path)) {
        dir <- rstudioapi::getActiveProject()
    } else {
        dir <- dirname(active_path)
    }
    system2("open", shQuote(c("-a", "iTerm", dir)))
}
randy3k/sublimetext documentation built on April 8, 2020, 2:22 a.m.