From 9c269722926bfd2c2a8497bcf6a9f004c58c27df Mon Sep 17 00:00:00 2001
From: Daniel Lundin <dln@eintr.org>
Date: Tue, 29 Oct 2019 14:16:27 +0100
Subject: [PATCH] Add support for OSC 52 clipboard to work over mosh/without
 X11

---
 .tmux.conf | 9 ++++++++-
 bin/clip   | 3 +++
 2 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100755 bin/clip

diff --git a/.tmux.conf b/.tmux.conf
index b7721e7..00ae4af 100644
--- a/.tmux.conf
+++ b/.tmux.conf
@@ -3,15 +3,22 @@ set -g prefix ^o
 set -g base-index 1
 set -g display-panes-time 3000
 #set -s escape-time 7
-set -s escape-time 50
+set -s escape-time 10
 set -g status on
 set -g status-interval 30
 set -g terminal-overrides "xterm*:XT:smcup@:rmcup@:kUP5=\eOA:kDN5=\eOB:kLFT5=\eOD:kRIT5=\eOC"
 set -g terminal-overrides ",*:colors=256:smso=\e[3m:rmso=\e[23m:sitm=\e[3m:ritm=\e[23m"
 set -g terminal-overrides ",xterm-256color:Tc"
 set -ga terminal-overrides ",xterm-256color:Tc"
+set-option -ag terminal-overrides ",xterm-256color:Ms=\\E]52;c;%p2%s\\7"
 set -g default-terminal "xterm-256color"
 
+# clipboard
+set -g set-clipboard on
+bind-key ] paste-buffer -p
+
+
+
 set-option -g mouse on
 #bind -n WheelUpPane copy-mode
 
diff --git a/bin/clip b/bin/clip
new file mode 100755
index 0000000..d1c1c44
--- /dev/null
+++ b/bin/clip
@@ -0,0 +1,3 @@
+#!/bin/sh
+set -eo pipefail
+printf "\033]52;c;$(base64 -w0)\a"