knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
EXPERIMENTAL
Very rough sketch, many things are likely to change or break.
{tabs} extends {rstudioapi} to be able to conveniently close or move tabs, show diffs between unsaved and saved, restore tabs from cache etc.
Install with:
remotes::install_github("moodymudskipper/tabs")
tabs_
functions mostly take a tidy selection as their main arg, which is applied
on tab names. e.g. tabs_keep(starts_with("a"))
The most important functions:
tabs_keep()
keeps matched tabs open tabs_close()
closes matched tabstabs_select()
keeps matched tabs and attempts to reorder them (There are
some limitations, for instance viewed items than cannot be recreated and sorting
of untitled tabs is not robust)tabs_gather()
moves matched tabs to the right side of the current tabtabs_open()
opens new tabs by matching file namestabs_resurrect()
brings back scripts that were closed without being saved but
still live in the cache (this one doesn't use tidy selection)By default when closing a tab might cause losing unsaved changeds a diff is shown and a choice is proposed.
The usual tidy selection helpers can be used to select by tab name or file name, ignoring the extension.
Other helpers are available :
is_r()
, is_rmd()
restricts selection to R files or Rmd filesext_is()
restricts to file that matches the provided extension without "."code_matches()
restricts selection to files whose code matches the provided patterncode_uses()
restricts selection to R scripts whose code uses the provided variablestored_in()
restricts selection to files located in a given directory, optionally recursiveis_saved()
restricts selection to tabs that don't have unsaved modificationsThis package makes assumption on the way RStudio stores information about tabs, it's undocumented so the day they change it the package will break.
Luckily this should not be critical since this package is made for interactive use so hopefully whenever it breaks we can adapt and move on without much damage done.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.