<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>
    clipboard on skywirex
    
    </title>
    <link>https://skywirex.com/tags/clipboard/</link>
    <description>Recent content 
    
    in clipboard on skywirex
    </description>
    <generator>Hugo -- gohugo.io</generator>
    <language>vi-vn</language>
    
    
    <lastBuildDate>Thu, 03 Sep 2026 04:58:45 +0700</lastBuildDate>
    
    
        <atom:link href="https://skywirex.com/tags/clipboard/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Copy in Lazygit when using SSH</title>
      <link>https://skywirex.com/copy-in-lazygit-when-using-ssh/</link>
      <pubDate>Thu, 03 Sep 2026 04:58:45 +0700</pubDate>
      
      <guid>https://skywirex.com/copy-in-lazygit-when-using-ssh/</guid>
      <description>&lt;h1 id=&#34;copy-in-lazygit-when-using-ssh&#34;&gt;Copy in Lazygit when using SSH&lt;/h1&gt;
&lt;p&gt;When using Lazygit on a &lt;strong&gt;headless&lt;/strong&gt; server (no screen, no X11/Wayland) over SSH, pressing &lt;code&gt;y&lt;/code&gt; to copy (e.g. copying a commit hash, file name&amp;hellip;) will produce this error:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Error
write |1: broken pipe
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;root-cause&#34;&gt;Root cause&lt;/h2&gt;
&lt;p&gt;Lazygit copies data to the clipboard by calling an external system clipboard program such as &lt;code&gt;xclip&lt;/code&gt;, &lt;code&gt;xsel&lt;/code&gt; (X11) or &lt;code&gt;wl-copy&lt;/code&gt; (Wayland), then writes the data into that program&amp;rsquo;s stdin.&lt;/p&gt;
&lt;p&gt;On a headless server:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;There is no &lt;code&gt;$DISPLAY&lt;/code&gt; or &lt;code&gt;$WAYLAND_DISPLAY&lt;/code&gt; environment variable.&lt;/li&gt;
&lt;li&gt;The &lt;code&gt;xclip&lt;/code&gt;/&lt;code&gt;xsel&lt;/code&gt;/&lt;code&gt;wl-copy&lt;/code&gt; commands cannot connect to a display server, so they &lt;strong&gt;exit immediately&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Lazygit still tries to write data into the stdin of the already-exited process → the pipe is closed → error &lt;strong&gt;&lt;code&gt;write |1: broken pipe&lt;/code&gt;&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;solution-use-osc-52&#34;&gt;Solution: use OSC 52&lt;/h2&gt;
&lt;p&gt;OSC 52 is an escape sequence that allows a program inside a terminal to send data straight into the &lt;strong&gt;local machine&amp;rsquo;s&lt;/strong&gt; clipboard (the machine you SSH from), without needing a clipboard backend on the server. It is supported by modern terminals: iTerm2, kitty, WezTerm, Windows Terminal, newer Alacritty, and more.&lt;/p&gt;
&lt;h3 id=&#34;step-1--find-the-config-directory&#34;&gt;Step 1 — Find the config directory&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;lazygit -cd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;(prints the config directory, e.g. &lt;code&gt;/root/.config/lazygit&lt;/code&gt;)&lt;/p&gt;
&lt;h3 id=&#34;step-2--write-the-osc-52-config-into-configyml&#34;&gt;Step 2 — Write the OSC 52 config into &lt;code&gt;config.yml&lt;/code&gt;&lt;/h3&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;cat &amp;gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;$(&lt;/span&gt;lazygit -cd&lt;span style=&#34;color:#66d9ef&#34;&gt;)&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;/config.yml&amp;#34;&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;lt;&amp;lt; &amp;#39;EOF&amp;#39;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;os:
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;  copyToClipboardCmd: &amp;#34;printf &amp;#39;\x1b]52;c;%s\a&amp;#39; \&amp;#34;$(cat {{filename}} | base64 | tr -d &amp;#39;\n&amp;#39;)\&amp;#34;&amp;#34;
&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;EOF&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Important note:&lt;/strong&gt; use &lt;code&gt;\x1b&lt;/code&gt; (hex escape) and &lt;strong&gt;not&lt;/strong&gt; &lt;code&gt;\033&lt;/code&gt; (octal escape). YAML only supports hex/unicode escapes, not octal. If you use &lt;code&gt;\033&lt;/code&gt;, YAML will misinterpret it as the character &lt;code&gt;\0&lt;/code&gt; (NUL) followed by &lt;code&gt;33&lt;/code&gt;, inserting a null byte into the command string, causing Go&amp;rsquo;s &lt;code&gt;exec&lt;/code&gt; to fail:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;fork/exec /bin/bash: invalid argument
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;(because the command string contains a NUL byte — which C strings / exec do not permit).&lt;/p&gt;
&lt;h3 id=&#34;step-3--restart-lazygit-and-try-copying&#34;&gt;Step 3 — Restart Lazygit and try copying&lt;/h3&gt;
&lt;p&gt;Open Lazygit again, press &lt;code&gt;y&lt;/code&gt; on the commit or file you want to copy. The content will be sent directly to your local machine&amp;rsquo;s clipboard via the terminal.&lt;/p&gt;
&lt;h2 id=&#34;notes-for-tmuxscreen-users&#34;&gt;Notes for tmux/screen users&lt;/h2&gt;
&lt;p&gt;If you run Lazygit inside &lt;code&gt;tmux&lt;/code&gt;, the OSC 52 escape sequence may be blocked in transit. Enable:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;set -g set-clipboard on
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;in &lt;code&gt;~/.tmux.conf&lt;/code&gt;, or configure pass-through separately depending on your tmux version.&lt;/p&gt;
&lt;h2 id=&#34;notes-for-herdr-users&#34;&gt;Notes for Herdr users&lt;/h2&gt;
&lt;p&gt;&lt;a href=&#34;https://herdr.dev/&#34;&gt;Herdr&lt;/a&gt; is a terminal workspace manager for AI coding agents, and it also acts as an intermediate terminal layer. When Lazygit runs inside Herdr, the OSC 52 sequence must pass through Herdr before being forwarded to the host&amp;rsquo;s real terminal.&lt;/p&gt;
&lt;p&gt;This is a &lt;strong&gt;known bug&lt;/strong&gt; in Herdr itself (issue &lt;a href=&#34;https://github.com/herdrdev/herdr/issues/2399&#34;&gt;#2399&lt;/a&gt;): when copying content from an application running inside Herdr, the &amp;ldquo;copied to clipboard&amp;rdquo; message still appears, but the content does &lt;strong&gt;not&lt;/strong&gt; actually reach the system clipboard — pasting (Ctrl+V) still shows the old content. This bug only occurs when Herdr runs in default (local) mode; when running with &lt;code&gt;herdr --remote&lt;/code&gt;, clipboard works normally.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Workaround:&lt;/strong&gt; start Herdr with the &lt;code&gt;--remote&lt;/code&gt; flag:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;herdr --remote
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;copyToClipboardCmd&lt;/code&gt; configuration in Lazygit (as described above) is still correct and necessary — the issue lies in Herdr not forwarding OSC 52 to the outer terminal when running locally, not in Lazygit or the YAML config.&lt;/p&gt;
&lt;h2 id=&#34;summary&#34;&gt;Summary&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Error / Symptom&lt;/th&gt;
&lt;th&gt;Root cause&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;write |1: broken pipe&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;No clipboard backend (&lt;code&gt;xclip&lt;/code&gt;/&lt;code&gt;wl-copy&lt;/code&gt;) on a headless server — no display server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;fork/exec /bin/bash: invalid argument&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Using &lt;code&gt;\033&lt;/code&gt; (octal) in a YAML double-quoted string → NUL byte in the command string, Go exec rejects it&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Copy reports success but host clipboard doesn&amp;rsquo;t receive it&lt;/td&gt;
&lt;td&gt;Running inside Herdr in local mode — Herdr doesn&amp;rsquo;t forward OSC 52 to the outer terminal (needs &lt;code&gt;herdr --remote&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;General solution:&lt;/strong&gt; configure &lt;code&gt;copyToClipboardCmd&lt;/code&gt; to use OSC 52 (&lt;code&gt;\x1b]52;c;...&lt;/code&gt;) to send clipboard data through the terminal, independent of GUI/display server on the remote machine.&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>