-
Notifications
You must be signed in to change notification settings - Fork 125
Closed
Description
Not sure this is the right place for this, but just in case it'd helpful to anyone running into similar situation. I use vscode (and its variants) to do work on my server over remote-SSH. Oftentimes, I want to view interactive maps created used tmap in vscode Terminal (R or radian), but the maps would not show up in vscode Viewer tab. (mapview works out of the box for this use case.) I figured out a solution (with the help of Claude) by setting the viewer option:
options(viewer = function(url, ...) {
# Extract the directory path from the URL
dir_path <- dirname(gsub("file:///", "", url))
# Start the server in that directory
servr::httd(dir = dir_path, port = 4321, daemon = TRUE)
# Open the file in browser using the server URL
file_name <- basename(url)
browseURL(paste0("http://localhost:4321/", file_name))
})
You can put it in .Rprofile with a check for interactive session and vscode terminal: if (interactive() && Sys.getenv("TERM_PROGRAM") == "vscode") {...}
Metadata
Metadata
Assignees
Labels
No labels