Skip to content

Instantly share code, notes, and snippets.

@bketelsen
Last active March 5, 2024 14:23
Show Gist options
  • Save bketelsen/27c2cd5b1376e72e240321baa0fbc81a to your computer and use it in GitHub Desktop.
Save bketelsen/27c2cd5b1376e72e240321baa0fbc81a to your computer and use it in GitHub Desktop.
how to use lemonade to share a clipboard between remote computers
on local and remote machine:
go get github.com/pocke/lemonade (if you have Go installed, if not download lemonade binary from github)
make sure $GOPATH/bin is in your path on both machines
-- or move $GOPATH/bin/lemonade to a place already in your path like /usr/local/bin
on your local machine add a script like this:
cat ~/bin/remote
#!/bin/bash
ps cax | grep lemonade> /dev/null
if [ $? -eq 0 ]; then
echo "lemonade is running."
else
echo "lemonade is not running."
nohup lemonade server &
fi
ssh -R 2489:127.0.0.1:2489 remote.server.com
then chmod +x ~/bin/remote
when you type `remote` it will open lemonade server locally, ssh tunnel the lemonade clipboard port.
locally (like on my mac) cmd-C to copy something.
this works between any two computers, even if one of them is a vm on the same machine
remote - $> lemonade paste
OR use the amazing neovim which has built-in lemonade support and just type "p" in neovim to paste the contents
of your local clipboard to your remote neovim session buffer.
for bonus points, modify the script to use a variable to invoke it with the remote server name:
$ remote my.server.com
@hzcheney
Copy link

hzcheney commented Nov 3, 2022

Thanks a lot! This really helps me!

@mj2068
Copy link

mj2068 commented Jan 7, 2023

incredible. thx

@NeilGirdhar
Copy link

NeilGirdhar commented Jul 6, 2023

Instead of that ssh command, you can add this line to the servers in your ssh config:

    RemoteForward 2489 localhost:2489  # Lemonade

and just start the server in your .bashrc. Then you can keep using ssh as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment