aboutsummaryrefslogtreecommitdiff
path: root/docs/index.xml
diff options
context:
space:
mode:
authorAkshay <[email protected]>2024-11-27 23:01:48 +0000
committerAkshay <[email protected]>2024-11-27 23:01:48 +0000
commit92a1fd5c5ee1fb0b4079128a0b7c6a1d78a2399d (patch)
tree3d1b106db2ca2824d4afffdc433a084e14675772 /docs/index.xml
parent9828c78d95f2195cd8e1db04887072cd5f48005b (diff)
new post: OSC-52
Diffstat (limited to 'docs/index.xml')
-rw-r--r--docs/index.xml53
1 files changed, 53 insertions, 0 deletions
diff --git a/docs/index.xml b/docs/index.xml
index eec76ca..f8b2aeb 100644
--- a/docs/index.xml
+++ b/docs/index.xml
@@ -12,6 +12,59 @@
12 <language>en-us</language> 12 <language>en-us</language>
13 <copyright>Creative Commons BY-NC-SA 4.0</copyright> 13 <copyright>Creative Commons BY-NC-SA 4.0</copyright>
14 <item> 14 <item>
15<title>OSC-52</title>
16<description>&lt;p&gt;I use &lt;code&gt;ssh&lt;/code&gt; a lot. Copying text from the remote machine to
17the host machine always sucked. But OSC-52 makes that easy.&lt;/p&gt;
18&lt;p&gt;OSC-52 is an ANSI escape sequence to write text to the terminal
19emulator. The terminal emulator, if it understands what is going on,
20will in turn write this text to the system clipboard.&lt;/p&gt;
21&lt;p&gt;What this means is some &lt;code&gt;printf&lt;/code&gt; magic can send text to
22your clipboard. I store this one-liner in a script called
23&lt;code&gt;oclip&lt;/code&gt;:&lt;/p&gt;
24&lt;div class="sourceCode" id="cb1"&gt;&lt;pre
25class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb1-1"&gt;&lt;a href="#cb1-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="bu"&gt;printf&lt;/span&gt; &lt;span class="st"&gt;&amp;quot;\033]52;c;%s\007&amp;quot;&lt;/span&gt; &lt;span class="st"&gt;&amp;quot;&lt;/span&gt;&lt;span class="va"&gt;$(&lt;/span&gt;&lt;span class="fu"&gt;base64&lt;/span&gt; &lt;span class="op"&gt;&amp;lt;&amp;amp;&lt;/span&gt;&lt;span class="dv"&gt;0&lt;/span&gt;&lt;span class="va"&gt;)&lt;/span&gt;&lt;span class="st"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
26&lt;p&gt;and I run it with:&lt;/p&gt;
27&lt;div class="sourceCode" id="cb2"&gt;&lt;pre
28class="sourceCode bash"&gt;&lt;code class="sourceCode bash"&gt;&lt;span id="cb2-1"&gt;&lt;a href="#cb2-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="ex"&gt;remote&lt;/span&gt; $ cat some_file.txt &lt;span class="kw"&gt;|&lt;/span&gt; &lt;span class="ex"&gt;oclip&lt;/span&gt;&lt;/span&gt;
29&lt;span id="cb2-2"&gt;&lt;a href="#cb2-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;/span&gt;
30&lt;span id="cb2-3"&gt;&lt;a href="#cb2-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="co"&gt;# some_file.txt&amp;#39;s contents are now the host&amp;#39;s clipboard&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
31&lt;h3 id="the-catch"&gt;The catch&lt;/h3&gt;
32&lt;p&gt;Your terminal emulator must support OSC-52, &lt;code&gt;alacritty&lt;/code&gt;
33and &lt;code&gt;termux&lt;/code&gt; seem to support this out of the box. In
34&lt;code&gt;st&lt;/code&gt;, OSC-52 works with this change to
35&lt;code&gt;config.h&lt;/code&gt;:&lt;/p&gt;
36&lt;pre&gt;&lt;code&gt;int allowwindowops = 1;&lt;/code&gt;&lt;/pre&gt;
37&lt;p&gt;If you are using &lt;code&gt;tmux&lt;/code&gt;, you need to flip this switch
38on:&lt;/p&gt;
39&lt;pre&gt;&lt;code&gt;set -s set-clipboard on&lt;/code&gt;&lt;/pre&gt;
40&lt;p&gt;If you are inside &lt;code&gt;nvim&lt;/code&gt;, it may work as expected as long
41as &lt;code&gt;$SSH_TTY&lt;/code&gt; is set. I sometimes physically start a session,
42and &lt;code&gt;ssh&lt;/code&gt; into the same session later from another machine,
43and &lt;code&gt;$SSH_TTY&lt;/code&gt; remains unset, so I force OSC-52 in
44&lt;code&gt;nvim&lt;/code&gt; at all times (see &lt;a
45href="https://neovim.io/doc/user/provider.html#clipboard-osc52"&gt;nvimdoc&lt;/a&gt;):&lt;/p&gt;
46&lt;div class="sourceCode" id="cb5"&gt;&lt;pre
47class="sourceCode lua"&gt;&lt;code class="sourceCode lua"&gt;&lt;span id="cb5-1"&gt;&lt;a href="#cb5-1" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="va"&gt;vim&lt;/span&gt;&lt;span class="op"&gt;.&lt;/span&gt;&lt;span class="va"&gt;g&lt;/span&gt;&lt;span class="op"&gt;.&lt;/span&gt;&lt;span class="va"&gt;clipboard&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="op"&gt;{&lt;/span&gt;&lt;/span&gt;
48&lt;span id="cb5-2"&gt;&lt;a href="#cb5-2" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;name&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="st"&gt;&amp;#39;OSC 52&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;,&lt;/span&gt;&lt;/span&gt;
49&lt;span id="cb5-3"&gt;&lt;a href="#cb5-3" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;copy&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="op"&gt;{&lt;/span&gt;&lt;/span&gt;
50&lt;span id="cb5-4"&gt;&lt;a href="#cb5-4" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;[&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;+&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;]&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="fu"&gt;require&lt;/span&gt;&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;vim.ui.clipboard.osc52&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;).&lt;/span&gt;copy&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;+&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;),&lt;/span&gt;&lt;/span&gt;
51&lt;span id="cb5-5"&gt;&lt;a href="#cb5-5" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;[&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;]&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="fu"&gt;require&lt;/span&gt;&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;vim.ui.clipboard.osc52&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;).&lt;/span&gt;copy&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;),&lt;/span&gt;&lt;/span&gt;
52&lt;span id="cb5-6"&gt;&lt;a href="#cb5-6" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;},&lt;/span&gt;&lt;/span&gt;
53&lt;span id="cb5-7"&gt;&lt;a href="#cb5-7" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="va"&gt;paste&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="op"&gt;{&lt;/span&gt;&lt;/span&gt;
54&lt;span id="cb5-8"&gt;&lt;a href="#cb5-8" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;[&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;+&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;]&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="fu"&gt;require&lt;/span&gt;&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;vim.ui.clipboard.osc52&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;).&lt;/span&gt;paste&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;+&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;),&lt;/span&gt;&lt;/span&gt;
55&lt;span id="cb5-9"&gt;&lt;a href="#cb5-9" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;[&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;]&lt;/span&gt; &lt;span class="op"&gt;=&lt;/span&gt; &lt;span class="fu"&gt;require&lt;/span&gt;&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;vim.ui.clipboard.osc52&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;).&lt;/span&gt;paste&lt;span class="op"&gt;(&lt;/span&gt;&lt;span class="st"&gt;&amp;#39;*&amp;#39;&lt;/span&gt;&lt;span class="op"&gt;),&lt;/span&gt;&lt;/span&gt;
56&lt;span id="cb5-10"&gt;&lt;a href="#cb5-10" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt; &lt;span class="op"&gt;},&lt;/span&gt;&lt;/span&gt;
57&lt;span id="cb5-11"&gt;&lt;a href="#cb5-11" aria-hidden="true" tabindex="-1"&gt;&lt;/a&gt;&lt;span class="op"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
58&lt;p&gt;If you are inside &lt;code&gt;nvim&lt;/code&gt; inside &lt;code&gt;tmux&lt;/code&gt; inside
59an &lt;code&gt;ssh&lt;/code&gt; session inside &lt;code&gt;st&lt;/code&gt;, you neeed all of the
60above tweaks. &lt;code&gt;nvim&lt;/code&gt; will pass the contents around to
61&lt;code&gt;tmux&lt;/code&gt;, which in turn will pass the contents to
62&lt;code&gt;st&lt;/code&gt;, which should pass it to your system clipboard.&lt;/p&gt;</description>
63<link>https://peppe.rs/posts/OSC-52/</link>
64<pubDate>Wed, 27 Nov 2024 22:56:00 +0000</pubDate>
65<guid>https://peppe.rs/posts/OSC-52/</guid>
66</item>
67<item>
15<title>Introducing Tablespoon</title> 68<title>Introducing Tablespoon</title>
16<description>&lt;p&gt;&lt;a href="https://git.peppe.rs/languages/tbsp"&gt;tbsp&lt;/a&gt; (tree-based 69<description>&lt;p&gt;&lt;a href="https://git.peppe.rs/languages/tbsp"&gt;tbsp&lt;/a&gt; (tree-based
17source-processing language) is an awk-like language that operates on 70source-processing language) is an awk-like language that operates on