Skip to content

Instantly share code, notes, and snippets.

@tukachev
Last active April 10, 2016 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tukachev/4e8aa973e30bbd1f46e29b1bffe71be7 to your computer and use it in GitHub Desktop.
Save tukachev/4e8aa973e30bbd1f46e29b1bffe71be7 to your computer and use it in GitHub Desktop.
clipboard in linux: copy&paste
# only works in linux
# Install xclip first
# $ sudo apt-get install xclip
# write to clipboard
wclip <- function(x, sep="\t", row.names=FALSE, col.names=TRUE){
con <- pipe("xclip -selection clipboard -i", open="w")
write.table(x, con, sep=sep, row.names=row.names, col.names=col.names)
close(con)
}
#read from clipboard
rclip <- function(){
con <- pipe("xclip -selection clipboard -o")
d <- read.delim2(con)
return(d)
close(con)
}
# Example
wclip(1:10)
wclip(letters)
wclip(matrix(1:15, nrow = 5))
data <- rclip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment