From 92a1fd5c5ee1fb0b4079128a0b7c6a1d78a2399d Mon Sep 17 00:00:00 2001 From: Akshay Date: Thu, 28 Nov 2024 04:31:48 +0530 Subject: new post: OSC-52 --- docs/posts/OSC-52/index.html | 119 +++++++++++++++++++++ docs/posts/auto-currying_rust_functions/index.html | 2 +- docs/posts/bash_harder_with_vim/index.html | 2 +- docs/posts/call_to_ARMs/index.html | 2 +- docs/posts/color_conundrum/index.html | 2 +- docs/posts/font_size_fallacies/index.html | 2 +- docs/posts/index.html | 43 +++++--- docs/posts/introducing_tablespoon/index.html | 2 +- docs/posts/my_setup/index.html | 2 +- docs/posts/pixel_art_in_GIMP/index.html | 2 +- docs/posts/plain_text_journaling/index.html | 2 +- docs/posts/rapid_refactoring_with_vim/index.html | 2 +- docs/posts/static_sites_with_bash/index.html | 2 +- docs/posts/termux_tandem/index.html | 2 +- docs/posts/turing_complete_type_systems/index.html | 2 +- 15 files changed, 162 insertions(+), 26 deletions(-) create mode 100644 docs/posts/OSC-52/index.html (limited to 'docs/posts') diff --git a/docs/posts/OSC-52/index.html b/docs/posts/OSC-52/index.html new file mode 100644 index 0000000..6c87fef --- /dev/null +++ b/docs/posts/OSC-52/index.html @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + OSC-52 · peppe.rs + +
+
+ Home + / + Posts + / + OSC-52 + View Raw +
+
+ 28/11 — 2024 +
+ + 26.37 + + cm +   + + 1.9 + + min +
+
+

+ OSC-52 +

+
+

I use ssh a lot. Copying text from the remote machine to +the host machine always sucked. But OSC-52 makes that easy.

+

OSC-52 is an ANSI escape sequence to write text to the terminal +emulator. The terminal emulator, if it understands what is going on, +will in turn write this text to the system clipboard.

+

What this means is some printf magic can send text to +your clipboard. I store this one-liner in a script called +oclip:

+
printf "\033]52;c;%s\007" "$(base64 <&0)"
+

and I run it with:

+
remote $ cat some_file.txt | oclip
+
+# some_file.txt's contents are now the host's clipboard
+

The catch

+

Your terminal emulator must support OSC-52, alacritty +and termux seem to support this out of the box. In +st, OSC-52 works with this change to +config.h:

+
int allowwindowops = 1;
+

If you are using tmux, you need to flip this switch +on:

+
set -s set-clipboard on
+

If you are inside nvim, it may work as expected as long +as $SSH_TTY is set. I sometimes physically start a session, +and ssh into the same session later from another machine, +and $SSH_TTY remains unset, so I force OSC-52 in +nvim at all times (see nvimdoc):

+
vim.g.clipboard = {
+  name = 'OSC 52',
+  copy = {
+    ['+'] = require('vim.ui.clipboard.osc52').copy('+'),
+    ['*'] = require('vim.ui.clipboard.osc52').copy('*'),
+  },
+  paste = {
+    ['+'] = require('vim.ui.clipboard.osc52').paste('+'),
+    ['*'] = require('vim.ui.clipboard.osc52').paste('*'),
+  },
+}
+

If you are inside nvim inside tmux inside +an ssh session inside st, you neeed all of the +above tweaks. nvim will pass the contents around to +tmux, which in turn will pass the contents to +st, which should pass it to your system clipboard.

+ +
+ +
+ Hi. + +

I'm Akshay, programmer and pixel-artist. + I write open-source stuff. + I also design fonts: + scientifica, + curie. +

+

Reach out at oppili@irc.rizon.net.

+
+ + Home + / + Posts + / + OSC-52 + View Raw +
+
+ + diff --git a/docs/posts/auto-currying_rust_functions/index.html b/docs/posts/auto-currying_rust_functions/index.html index c06b13f..9ea7246 100644 --- a/docs/posts/auto-currying_rust_functions/index.html +++ b/docs/posts/auto-currying_rust_functions/index.html @@ -25,7 +25,7 @@ ">View Raw
- 08/05 — 2020 + 09/05 — 2020
356.44 diff --git a/docs/posts/bash_harder_with_vim/index.html b/docs/posts/bash_harder_with_vim/index.html index 6104163..7d3c869 100644 --- a/docs/posts/bash_harder_with_vim/index.html +++ b/docs/posts/bash_harder_with_vim/index.html @@ -25,7 +25,7 @@ ">View Raw
- 30/07 — 2019 + 31/07 — 2019
24.38 diff --git a/docs/posts/call_to_ARMs/index.html b/docs/posts/call_to_ARMs/index.html index 71b5397..f5b92f7 100644 --- a/docs/posts/call_to_ARMs/index.html +++ b/docs/posts/call_to_ARMs/index.html @@ -25,7 +25,7 @@ ">View Raw
- 07/02 — 2020 + 08/02 — 2020
33.57 diff --git a/docs/posts/color_conundrum/index.html b/docs/posts/color_conundrum/index.html index 87bc495..a98741a 100644 --- a/docs/posts/color_conundrum/index.html +++ b/docs/posts/color_conundrum/index.html @@ -25,7 +25,7 @@ ">View Raw
- 30/12 — 2019 + 31/12 — 2019
14.39 diff --git a/docs/posts/font_size_fallacies/index.html b/docs/posts/font_size_fallacies/index.html index 871a536..5cf8485 100644 --- a/docs/posts/font_size_fallacies/index.html +++ b/docs/posts/font_size_fallacies/index.html @@ -25,7 +25,7 @@ ">View Raw
- 16/03 — 2020 + 17/03 — 2020
32.37 diff --git a/docs/posts/index.html b/docs/posts/index.html index a8d321c..f70098b 100644 --- a/docs/posts/index.html +++ b/docs/posts/index.html @@ -27,7 +27,24 @@
- 01/08 — 2024 + 28/11 — 2024 +
+ + OSC-52 + + + + + 1.9 + + min + + + + + +
+ 02/08 — 2024
Introducing Tablespoon @@ -61,7 +78,7 @@
- 18/06 — 2023 + 19/06 — 2023
Plain Text Journaling @@ -248,7 +265,7 @@
- 17/06 — 2020 + 18/06 — 2020
Turing Complete Type Systems @@ -265,7 +282,7 @@
- 08/05 — 2020 + 09/05 — 2020
Auto-currying Rust Functions @@ -282,7 +299,7 @@
- 08/04 — 2020 + 09/04 — 2020
Pixel Art In GIMP @@ -299,7 +316,7 @@
- 31/03 — 2020 + 01/04 — 2020
Rapid Refactoring With Vim @@ -316,7 +333,7 @@
- 16/03 — 2020 + 17/03 — 2020
Font Size Fallacies @@ -333,7 +350,7 @@
- 07/03 — 2020 + 08/03 — 2020
Termux Tandem @@ -350,7 +367,7 @@
- 07/02 — 2020 + 08/02 — 2020
Call To ARMs @@ -367,7 +384,7 @@
- 30/12 — 2019 + 31/12 — 2019
Color Conundrum @@ -384,7 +401,7 @@
- 22/11 — 2019 + 23/11 — 2019
Static Sites With Bash @@ -401,7 +418,7 @@
- 06/11 — 2019 + 07/11 — 2019
My Setup @@ -469,7 +486,7 @@
- 30/07 — 2019 + 31/07 — 2019
Bash Harder With Vim diff --git a/docs/posts/introducing_tablespoon/index.html b/docs/posts/introducing_tablespoon/index.html index a6f6ef2..c097cfa 100644 --- a/docs/posts/introducing_tablespoon/index.html +++ b/docs/posts/introducing_tablespoon/index.html @@ -25,7 +25,7 @@ ">View Raw
- 01/08 — 2024 + 02/08 — 2024
72.33 diff --git a/docs/posts/my_setup/index.html b/docs/posts/my_setup/index.html index 9844d52..a5cdef5 100644 --- a/docs/posts/my_setup/index.html +++ b/docs/posts/my_setup/index.html @@ -25,7 +25,7 @@ ">View Raw
- 06/11 — 2019 + 07/11 — 2019
10.39 diff --git a/docs/posts/pixel_art_in_GIMP/index.html b/docs/posts/pixel_art_in_GIMP/index.html index 25db0ca..122fd35 100644 --- a/docs/posts/pixel_art_in_GIMP/index.html +++ b/docs/posts/pixel_art_in_GIMP/index.html @@ -25,7 +25,7 @@ ">View Raw
- 08/04 — 2020 + 09/04 — 2020
55.54 diff --git a/docs/posts/plain_text_journaling/index.html b/docs/posts/plain_text_journaling/index.html index b4b4c54..ae47471 100644 --- a/docs/posts/plain_text_journaling/index.html +++ b/docs/posts/plain_text_journaling/index.html @@ -25,7 +25,7 @@ ">View Raw
- 18/06 — 2023 + 19/06 — 2023
138.66 diff --git a/docs/posts/rapid_refactoring_with_vim/index.html b/docs/posts/rapid_refactoring_with_vim/index.html index cd10d02..622243d 100644 --- a/docs/posts/rapid_refactoring_with_vim/index.html +++ b/docs/posts/rapid_refactoring_with_vim/index.html @@ -25,7 +25,7 @@ ">View Raw
- 31/03 — 2020 + 01/04 — 2020
79.12 diff --git a/docs/posts/static_sites_with_bash/index.html b/docs/posts/static_sites_with_bash/index.html index 8e6441a..293fa62 100644 --- a/docs/posts/static_sites_with_bash/index.html +++ b/docs/posts/static_sites_with_bash/index.html @@ -25,7 +25,7 @@ ">View Raw
- 22/11 — 2019 + 23/11 — 2019
21.18 diff --git a/docs/posts/termux_tandem/index.html b/docs/posts/termux_tandem/index.html index 15eb01f..cf7fb77 100644 --- a/docs/posts/termux_tandem/index.html +++ b/docs/posts/termux_tandem/index.html @@ -25,7 +25,7 @@ ">View Raw
- 07/03 — 2020 + 08/03 — 2020
19.18 diff --git a/docs/posts/turing_complete_type_systems/index.html b/docs/posts/turing_complete_type_systems/index.html index 214e7ff..5a87edf 100644 --- a/docs/posts/turing_complete_type_systems/index.html +++ b/docs/posts/turing_complete_type_systems/index.html @@ -25,7 +25,7 @@ ">View Raw
- 17/06 — 2020 + 18/06 — 2020
9.19 -- cgit v1.2.3