R/copy_path.R

#' Pipeable Clipboard Copying
#'
#' This convenience function wraps \code{\link[clipr]{write_clip}} to copy the
#' previous output in the chain to the clipboard.
#'
#' @param x An object to be written to the system clipboard.
#' @param \ldots Other arguments passed to \code{\link[clipr]{write_clip}}.
#' @return Returns \code{x} but attempts to copy content to the clipboard.
#' @export
#' @examples
#' \dontrun{
#' library(magrittr)
#' files %>%
#'     parse_path() %>%
#'     swap_regex("^(P|R)", "oops") %>%
#'     copy_path()
#' }
copy_path <- function(x, ...){
    clipr::write_clip(x, ...)
    x
}
trinker/pathr documentation built on May 31, 2019, 9:41 p.m.