<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CodeWarrior4Life</title>
    <description>The latest articles on DEV Community by CodeWarrior4Life (@codewarrior4life).</description>
    <link>https://dev.to/codewarrior4life</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3864626%2F88c61e7c-ec1b-4813-8de0-16dbbb770ec1.png</url>
      <title>DEV Community: CodeWarrior4Life</title>
      <link>https://dev.to/codewarrior4life</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codewarrior4life"/>
    <language>en</language>
    <item>
      <title>I Got Tired of Hunting Screenshot Paths in Terminals. So I Fixed Ctrl+V.</title>
      <dc:creator>CodeWarrior4Life</dc:creator>
      <pubDate>Mon, 06 Apr 2026 22:10:38 +0000</pubDate>
      <link>https://dev.to/codewarrior4life/i-got-tired-of-hunting-screenshot-paths-in-terminals-so-i-fixed-ctrlv-5dbk</link>
      <guid>https://dev.to/codewarrior4life/i-got-tired-of-hunting-screenshot-paths-in-terminals-so-i-fixed-ctrlv-5dbk</guid>
      <description>&lt;h3&gt;
  
  
  The Idea
&lt;/h3&gt;

&lt;p&gt;The fix seemed obvious: Ctrl+V should be context-aware. If I'm in a terminal and I have an image on my clipboard, I probably want the file path, not the image data. If I'm in a text editor, paste normally. If I'm in a browser, paste normally.&lt;/p&gt;

&lt;p&gt;The key insight is that the behavior should be invisible. I didn't want a new command to memorize. I wanted Ctrl+V to just do the right thing depending on where I was.&lt;/p&gt;




&lt;h3&gt;
  
  
  How It Works
&lt;/h3&gt;

&lt;p&gt;TCP has two layers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The keyboard layer&lt;/strong&gt; is an AutoHotkey v2 script that runs in the background as a tray process. It intercepts Ctrl+V at the OS level. When you press it, AHK checks which window is focused. If it's a terminal, it hands off to the Python core. If it's not, it does nothing and lets the normal paste go through.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Python core&lt;/strong&gt; handles the logic:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Inspect the clipboard — is there image data?&lt;/li&gt;
&lt;li&gt;If yes: check the OS screenshot folder for a file that matches, using a recency window (default: 5 seconds). If the screenshot was captured in the last 5 seconds, it's almost certainly the one you want.&lt;/li&gt;
&lt;li&gt;If a match exists: type the full file path into the terminal.&lt;/li&gt;
&lt;li&gt;If no match exists: save the clipboard image to disk, then type the path.&lt;/li&gt;
&lt;li&gt;If no image in clipboard: fall back to normal paste behavior.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Alt+V is the override: it force-pastes the image path regardless of which window is focused. Useful when you're pasting into a GUI app that isn't a terminal but still needs a path.&lt;/p&gt;




&lt;h3&gt;
  
  
  Zero Config by Design
&lt;/h3&gt;

&lt;p&gt;I made a deliberate choice to require no setup. TCP works the moment you install it.&lt;/p&gt;

&lt;p&gt;Screenshot folder detection is automatic on every platform — Windows registry keys, macOS defaults, and XDG paths on Linux. No config file needed for the common case.&lt;/p&gt;

&lt;p&gt;Terminal detection uses a built-in list of process names: &lt;code&gt;WindowsTerminal.exe&lt;/code&gt;, &lt;code&gt;powershell.exe&lt;/code&gt;, &lt;code&gt;pwsh.exe&lt;/code&gt;, &lt;code&gt;cmd.exe&lt;/code&gt;, &lt;code&gt;Code.exe&lt;/code&gt;, &lt;code&gt;warp.exe&lt;/code&gt;, &lt;code&gt;alacritty.exe&lt;/code&gt;, &lt;code&gt;mintty.exe&lt;/code&gt;. You can add more in &lt;code&gt;%APPDATA%\tcp\config.toml&lt;/code&gt; if your terminal isn't covered.&lt;/p&gt;

&lt;p&gt;The config file is optional TOML for users who want to customize anything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight toml"&gt;&lt;code&gt;&lt;span class="py"&gt;save_dir&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;""&lt;/span&gt;                          &lt;span class="c"&gt;# Auto-detected from OS settings&lt;/span&gt;
&lt;span class="py"&gt;filename_pattern&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"tcp_%Y%m%d_%H%M%S.png"&lt;/span&gt;
&lt;span class="py"&gt;recency_window&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;                     &lt;span class="c"&gt;# Seconds&lt;/span&gt;
&lt;span class="py"&gt;format&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"png"&lt;/span&gt;
&lt;span class="py"&gt;path_style&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"native"&lt;/span&gt;                  &lt;span class="c"&gt;# native, forward, or backslash&lt;/span&gt;
&lt;span class="py"&gt;extra_terminals&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"hyper.exe"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Why AutoHotkey
&lt;/h3&gt;

&lt;p&gt;Keyboard interception at the OS level on Windows comes down to a few options: raw Win32 hooks in C/C++, PowerShell with P/Invoke, or AHK. I chose AHK because it's mature, well-understood in the Windows power-user community, and the v2 API is clean. The shim is about 50 lines. It does one thing: intercept hotkeys and shell out to Python.&lt;/p&gt;

&lt;p&gt;The Python core is where the logic lives. That also means it's cross-platform — the core already works on macOS and Linux. The missing piece for those platforms is just the hotkey interception layer (Swift/Hammerspoon for macOS, xdotool for Linux). That's on the roadmap.&lt;/p&gt;




&lt;h3&gt;
  
  
  What I Learned
&lt;/h3&gt;

&lt;p&gt;The hardest part wasn't the clipboard logic or the file matching — it was getting the AHK keystroke injection right. When TCP types a file path into a terminal, it uses AHK's &lt;code&gt;Send&lt;/code&gt; function. Early versions had a bug where modifier keys (Ctrl, Shift) from the intercepted hotkey would "leak" into the sent keystrokes, garbling the output. The fix was using &lt;code&gt;{Raw}&lt;/code&gt; and &lt;code&gt;{Blind}&lt;/code&gt; mode in AHK to ensure the send is clean.&lt;/p&gt;

&lt;p&gt;The second tricky part was the clipboard-swap approach for Ctrl+V passthrough. When TCP determines the paste should be a normal text paste, it needs to let the keypress go through as-is. Getting that right without synthetic keystrokes or double-fires took a few iterations.&lt;/p&gt;




&lt;h3&gt;
  
  
  What's Next
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;macOS support (the Swift hotkey shim is the main missing piece)&lt;/li&gt;
&lt;li&gt;Linux support (xdotool-based shim)&lt;/li&gt;
&lt;li&gt;Optional path quoting for paths with spaces&lt;/li&gt;
&lt;li&gt;Watcher mode — detect new screenshots in real time and pre-cache the path so the first Ctrl+V is instant even if the file write is slow&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Try It
&lt;/h3&gt;

&lt;p&gt;TCP is free. BSL 1.1 — free for all use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One-click installer:&lt;/strong&gt; &lt;a href="https://github.com/CodeWarrior4Life/TerminalCopyPaste/releases/latest" rel="noopener noreferrer"&gt;TCPSetup.exe&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PowerShell one-liner:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;irm&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;https://raw.githubusercontent.com/CodeWarrior4Life/TerminalCopyPaste/main/install.ps1&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;iex&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Repo:&lt;/strong&gt; &lt;a href="https://github.com/CodeWarrior4Life/TerminalCopyPaste" rel="noopener noreferrer"&gt;https://github.com/CodeWarrior4Life/TerminalCopyPaste&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you use Claude Code, Codex CLI, Aider, or any terminal-heavy workflow, give it a try.&lt;/p&gt;




&lt;p&gt;If you found this useful, consider &lt;a href="https://buymeacoffee.com/tfvmclmlwp" rel="noopener noreferrer"&gt;buying me a coffee&lt;/a&gt; to keep the ideas flowing. ☕ It's the kind of tool that becomes invisible after a day — which is exactly what I was going for.&lt;/p&gt;

</description>
      <category>python</category>
      <category>terminal</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
