clipd

command module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2020 License: MIT Imports: 1 Imported by: 0

README

clipd

Go

A simple clipboard written in Go with support for multiple registries. It includes:

  • An http server to read from and write to an embedded cache , data is received and transmitted as text/plain;
  • A fully configurable cli to start the server, yank (with pipes), and paste.

This project was inspired by this post. I have been spending some time with Go, and it seemed like a good idea to get some hands-on experience.

It probably needs some refactoring, and the test coverage leaves a lot to be desired, but it's a start.

Get/install

If you have Go installed, just go get -u github.com/nicolomaioli/clipd. You can also clone the repository and go build or go install. Binaries are not available at this time.

Configuration

Checkout the --help flag. You can also create a global config file $HOME/.clipd.yaml (or json, or toml, or any format supported by viper). Here's an example config:

server:
    address: ":8891"
    develop: false
    logLevel: 3
client:
    address: ":8891"

Start with Systemd

An example clipd.service (you will probably want to change User and the path to the executable in ExecStart):

[Unit]
Description=clipd server
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=pi
ExecStart=/home/pi/go/bin/clipd start -l 0

[Install]
WantedBy=multi-user.target

Put it in /etc/systemd/system/clipd.service, then:

# Set correct permissions
sudo chmod 644 /etc/systemd/system/clipd.service

# Start it
sudo systemctl start clipd.service

# Get the status
systemctl status clipd.service

# Enable it
sudo systemctl enable clipd.service

# Get the logs
journalctl -u clipd

Over SSH with port forwarding

If clipd is running on the target machine on port 8891, you can access it from your local machine with port forwarding:

ssh -L 9188:localhost:8891 user@host

Then, on the client, you can access the clipboard with:

echo "Hello world!" | clipd yank -a 9188
clipd paste -a 9188
# Hello world!

Neovim

:help g:clipboard for all the good stuff. Here is a minimal init.vim:

let g:clipboard = {
      \   'name': 'clipd',
      \   'copy': {
      \      '+': 'clipd yank',
      \      '*': 'clipd yank',
      \    },
      \   'paste': {
      \      '+': 'clipd paste',
      \      '*': 'clipd paste',
      \   },
      \ }

set clipboard+=unnamedplus

Tmux

You can specify your own clipboard in Tmux:

bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "clipd yank"
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "clipd paste"

Web UI

Adding a basic web UI is probably going to be the next step in the development of clipd. One consideration here is that the server reads and return text/plain content, so the output in particular should be properly sanitized before it hits the browser.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL