comparison unixSoft/bin/afcopy @ 480:4c5814d3cfd8

afcopy: some enhancements from Bryan's dotfiles This makes `afcopy` able to drop things in the clipboard over ssh. Wild stuff. See https://bitbucket.org/bcmills/dotfiles/src/101956eeb90160f1d225ae23c8e6566c9df91c5c/bin/clip?at=default&fileviewer=file-view-default for some details.
author Augie Fackler <raf@durin42.com>
date Thu, 14 Mar 2019 10:38:49 -0400
parents b5178986dcbb
children
comparison
equal deleted inserted replaced
479:601884c45f8a 480:4c5814d3cfd8
1 #!/bin/sh 1 #!/bin/sh
2 if [ `uname` = Darwin ] ; then 2 if [ `uname` = Darwin ] ; then
3 pbcopy 3 pbcopy
4 else 4 else
5 xclip -selection clipboard 5 if [ -z "${TMUX:-}" ]; then
6 DATA="$(cat)"
7 # Copy the data to the terminal clipboard using OSC 52 escape codes.
8 # See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html, “Ps = 5 2”.
9 echo -en '\e]52;c;'
10 echo -n "$DATA" | base64 -w0
11 echo -en '\a'
12 else
13 tmux set-buffer -- "$DATA"
14 # Use a double-escape to send escape codes directly to the terminal.
15 # See https://github.com/tmux/tmux/commit/79e30daeae1d49a1cf1dc4618edf1ec82804a80c.
16 echo -en '\ePtmux;\e\e]52;c;'
17 echo -n "$DATA" | base64 -w0
18 echo -en '\a\e\\'
19 fi
20 if [ -n "${DISPLAY:-}" ] ; then
21 xclip -selection clipboard
22 fi
6 fi 23 fi