Mercurial > dotfiles
annotate unixSoft/bin/afcopy @ 507:7d298a83fceb
emacs: reference toml instead of toml-mode, fix up some rust packages
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Mon, 04 Jan 2021 13:35:57 -0500 |
parents | 4c5814d3cfd8 |
children |
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 |