annotate unixSoft/bin/afcopy @ 520:9af1fc9b713c

zsh: enable iterm2 integration This is the iterm2 integration script as of today. Squinting a bit, this looks like the version of the file from https://github.com/gnachman/iTerm2/commit/3d8173763e1e7f53c08a7da52fc92db4e036395a, which is the most recent edit to the file on github.
author Augie Fackler <raf@durin42.com>
date Thu, 14 Jul 2022 14:08:25 -0400
parents 4c5814d3cfd8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
409
b5178986dcbb af{copy,paste}: scripts so I can copy/paste with pipes across platforms
Augie Fackler <raf@durin42.com>
parents:
diff changeset
1 #!/bin/sh
b5178986dcbb af{copy,paste}: scripts so I can copy/paste with pipes across platforms
Augie Fackler <raf@durin42.com>
parents:
diff changeset
2 if [ `uname` = Darwin ] ; then
b5178986dcbb af{copy,paste}: scripts so I can copy/paste with pipes across platforms
Augie Fackler <raf@durin42.com>
parents:
diff changeset
3 pbcopy
b5178986dcbb af{copy,paste}: scripts so I can copy/paste with pipes across platforms
Augie Fackler <raf@durin42.com>
parents:
diff changeset
4 else
480
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
5 if [ -z "${TMUX:-}" ]; then
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
6 DATA="$(cat)"
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
7 # Copy the data to the terminal clipboard using OSC 52 escape codes.
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
8 # See http://invisible-island.net/xterm/ctlseqs/ctlseqs.html, “Ps = 5 2”.
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
9 echo -en '\e]52;c;'
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
10 echo -n "$DATA" | base64 -w0
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
11 echo -en '\a'
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
12 else
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
13 tmux set-buffer -- "$DATA"
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
14 # Use a double-escape to send escape codes directly to the terminal.
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
15 # See https://github.com/tmux/tmux/commit/79e30daeae1d49a1cf1dc4618edf1ec82804a80c.
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
16 echo -en '\ePtmux;\e\e]52;c;'
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
17 echo -n "$DATA" | base64 -w0
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
18 echo -en '\a\e\\'
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
19 fi
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
20 if [ -n "${DISPLAY:-}" ] ; then
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
21 xclip -selection clipboard
4c5814d3cfd8 afcopy: some enhancements from Bryan's dotfiles
Augie Fackler <raf@durin42.com>
parents: 409
diff changeset
22 fi
409
b5178986dcbb af{copy,paste}: scripts so I can copy/paste with pipes across platforms
Augie Fackler <raf@durin42.com>
parents:
diff changeset
23 fi