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