Last active
August 29, 2015 14:00
-
-
Save id/a6eefcadafb9ca9de5a4 to your computer and use it in GitHub Desktop.
Share tmux buffer between hosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .tmux.conf: | |
bind-key -temacs-copy M-w copy-pipe "tmux_send_clip.sh" | |
# cat $HOME/bin/tmux_send_clip.sh: | |
#!/bin/sh | |
function maybe_show_err { | |
if [ $? -ne 0 ] | |
then | |
ERROR=$(</tmp/err) | |
tmux display-message "$? $ERROR" | |
fi | |
} | |
cat >/tmp/clip | |
cat /tmp/clip | ssh u@h1 "cat >/tmp/clip; tmux load-buffer /tmp/clip" 2> /tmp/err | |
maybe_show_err | |
cat /tmp/clip | ssh -o ConnectTimeout=1 -o ConnectionAttempts=1 u@h2 "cat | pbcopy" 2> /tmp/err | |
maybe_show_err | |
# cat $HOME/bin/emacs_share_buffer.sh | |
#!/bin/sh | |
tmux set-buffer "$1" | |
echo -n "$1" | tmux_send_clip.sh | |
# .emacs.d/init.el or .emacs | |
(defun my-cut-function (text &optional rest) | |
(let ((process-connection-type nil)) | |
(start-process "emacs_share_buffer.sh" "*Messages*" "emacs_share_buffer.sh" text))) | |
(setq interprogram-cut-function 'my-cut-function) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment