Coder Social home page Coder Social logo

copiepate's Introduction

Copiepate

Build Crates.io License

Copiepate is a small utility to remotely set the content of a clipboard.

I created this tool as I frequently use a remote tmux+vim setup and I often need to copy a vim register to my local desktop.

copiepate animation

Usage

On your local desktop start the daemon in server mode and forward the port 2323 using ssh:

# Start copiepate server and listen on 127.0.0.1:2323:
copiepate --server

# In another shell, forward the server port to a remote machine:
ssh remote-machine -N -R 2323:localhost:2323

On the remote machine, copiepate sends the content of stdin to the local machine clipboard:

# Set the clipboard content of the local machine:
echo -n "New clipboard content" | copiepate

Setup and Installation

Using Rust Cargo:

# On GNU+Linux you'll need xorg-dev libraries.
# On other OSes (MacOS and Windows) this step is unecessary.

# Ubuntu/Debian:
sudo apt install xorg-dev libxcb-shape0-dev libxcb-xfixes0-dev

# Install copiepate (both server and client) using cargo:
cargo install copiepate


# IMPORTANT: generate a unique secret key that will be shared
# between on the client and the server using openssl:
openssl rand -base64 32

# Create a configuration file (both server and client) with a scret:
mkdir -p ~/.config/copiepate
cat  << EOF > ~/.config/copiepate/config.toml
secret = "<insert secret generated by openssl>"
EOF

Vim integration

You can use copiepate to send the content of a vim register over the network:

" Using Plug as plugin manager:
Plug 'dimtion/copiepate', { 'rtp': 'vim' }

This plugin creates the following default bindings:

" Send the default register
noremap <leader>y :CopiePateReg<CR>

" In visual mode, send current selection
vnoremap <leader>y :CopiePate<CR>

Configuration file

Copiepate supports having a configuration file to persist configuration. Every setting can either be stored in the config file or by a command line argument. Any setting set in the configuration file will be overriden by parameters passed to the command line.

See full list of settings running copiepate --help.

# Copiepate XDG configuration file:
# ~/.config/copiepate/config.toml

# Bind to a specific address
# Optional, default = 127.0.0.1
address = "192.168.0.2"

# Bind to a non default port
# Optional, default = 2323
port = "2325"

# Set a secret in base64 format
secret = "/f7NyvhS4k90gnstzXVPk/SpRl/Ex4EX9tyHRA2rT0w="

# [Server only]
# Specify a shell command to invoke whenever a paste event is received.
# Optional, default = ""
#
# Some examples:
# Show notification in MacOS:
# exec = "xargs -I % -0 -n 1 osascript -e \"display notification \\\"%\\\" with title \\\"Copiepate\\\"\""
#
# Show notification on GNU+Linux:
# exec = "xargs -I % -0 -n 1 notify-send \"%\""
#
# Log copy events to disk:
# exec = "cat >> copiepate_events.log"
#
# Ring terminal bell:
exec = "echo -en \"\007\""

# [Client only]
# Use copiepate as a passthrough. This allows to split an stdin between the send event and stdout.
# Optional, default = false
#
# Usage example:
# $ input_process | copiepate --tee > remove_copy_of_input_process.txt
tee = true

Note on security

In its default configuration, copiepate listens only on the localhost address, meaning that the port is not exposed to the local network.

WARNING: copiepate use encryption to ensure that attackers can't send paste event or evedrop what messages are in transit over the network. However copiepate was not audited. I recommend to only listen on a localhost port and only forward the port using a secure protocol such as SSH, and not expose copiepate server to a local network or the internet.

copiepate's People

Contributors

dimtion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

developerworks

copiepate's Issues

Fail to build copiepate

Hello,
I'm trying to install your tool using cargo on debian, however the compilation fails:

error[E0369]: binary operation `==` cannot be applied to type `proc_macro::Punct`
  --> /home/nimag42/.cargo/registry/src/github.com-1ecc6299db9ec823/time-macros-0.2.3/src/helpers/mod.rs:69:49
   |
69 |         Some(TokenTree::Punct(punct)) if *punct == c => {
   |                                          ------ ^^ - char
   |                                          |
   |                                          proc_macro::Punct

For more information about this error, try `rustc --explain E0369`.
error: could not compile `time-macros` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `copiepate v0.1.0`, intermediate artifacts can be found at `/tmp/cargo-installlyq0hb`

Here is my current version of cargo and lib:

gorgeousPineapple ~ % cargo -V                                       
cargo 1.56.0
gorgeousPineapple ~ % apt-cache policy xorg-dev libxcb-shape0-dev libxcb-xfixes0-dev|grep Install -B1
xorg-dev:               
  Installé : 1:7.7+23
--
libxcb-shape0-dev:
  Installé : 1.14-3
--
libxcb-xfixes0-dev:
  Installé : 1.14-3

Do you need more information?

Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.