DEV Community

Suraj Fale
Suraj Fale

Posted on • Originally published at github.com

Your New Command Line Co-Pilot: Mastering the Clipboard with Rust

✂️ Rusty Clipboard: The Power User's Terminal-First Clipboard Manager for Windows 11

Tired of juggling multiple clipboard items across applications? Meet **rusty-clipboard—a blazing-fast, terminal-native clipboard manager that brings Vim-like efficiency to your Windows workflow! 🚀

🎯 What Problem Does It Solve?

Every developer knows the pain: you copy a code snippet 📋, then an error message 🚨, then a URL 🔗... and suddenly your original content is gone forever. Traditional clipboard managers often feel clunky, requiring mouse interactions or disrupting your flow.

rusty-clipboard solves this with a fresh approach: terminal-first design + Vim-inspired navigation + Windows-native performance. It's like having a clipboard assistant that lives in your terminal, always ready but never intrusive! ✨

🏗️ Architectural Brilliance: Two Processes, One Mission

The secret sauce? Process separation! 🧠 rusty-clipboard splits responsibilities between two specialized components:

// Daemon (clipd) - The silent guardian
async fn main() -> Result<()> {
    let clipboard_watcher = ClipboardWatcher::new();
    let db = SqliteStore::new().await?;
    let ipc_server = IpcServer::start().await?;

    // Watch, capture, persist - all in the background
    clipboard_watcher.run(db, ipc_server).await
}

// TUI (clipctl) - The elegant interface
fn main() -> Result<()> {
    let app = App::new()?;
    let mut terminal = Terminal::new()?;

    // Render, search, interact - with zero impact on capture
    terminal.draw(|f| ui::draw(f, &app))?;
}
Enter fullscreen mode Exit fullscreen mode

This separation means your clipboard history never disappears, even if the UI crashes or you restart it! 🔒 The daemon (clipd) runs continuously, while the TUI (clipctl) launches on-demand with a simple F12 hotkey.

⚡ Core Features That Will Blow Your Mind

🎨 Beautiful, Information-Rich Terminal UI

Forget boring text lists! rusty-clipboard delivers a visually stunning TUI experience:

  • Multiple Color Themes 🌈: Choose from Nord (default), Dracula, Tokyo Night, or Gruvbox—each carefully crafted for optimal readability
  • Smart Syntax Highlighting 💻: Automatically detects and highlights code in 10+ languages including Rust, Python, JavaScript, and Go
  • Rich Text Rendering 📄: Renders markdown-style formatting with headers, bullet points, and inline code blocks
  • Colored Icon System 🎯: Different colors for text (📝), URLs (🔗), images (🖼️), and documents (📄)

🔍 Vim-Style Navigation & Search

If you love Vim, you'll feel right at home! 🏠

Normal Mode:
j/k    - Navigate up/down
g/G    - Jump to top/bottom
/      - Enter search mode
Enter  - Paste selected item
?      - Show help overlay
q      - Quit without pasting

Search Mode:
Type your query - Real-time filtering
Enter/Esc      - Exit search
Enter fullscreen mode Exit fullscreen mode

The search is incremental and server-side, meaning even massive clipboard histories feel instantaneous! ⚡

🗄️ Intelligent Persistence & Deduplication

No more duplicate entries clogging your history! The system uses SHA-256 hashing to detect and suppress adjacent duplicates:

impl ClipboardEntry {
    pub fn deduplicate(&self, previous_hash: &str) -> bool {
        let current_hash = compute_sha256(&self.content);
        current_hash != previous_hash
    }
}
Enter fullscreen mode Exit fullscreen mode

SQLite in WAL mode ensures sub-5ms writes while handling concurrent reads flawlessly. Your history stays local and private—no cloud nonsense! 🔐

🛠️ Technical Deep Dive: How It Actually Works

📡 Clipboard Capture Magic

rusty-clipboard uses a dual-strategy approach to never miss a clipboard change:

// Primary: Real-time listener (most efficient)
unsafe { AddClipboardFormatListener(hwnd) };

// Fallback: Polling for sandboxed apps
tokio::spawn(async {
    loop {
        let seq = unsafe { GetClipboardSequenceNumber() };
        if seq != last_seq {
            process_clipboard_change().await;
        }
        sleep(Duration::from_millis(250)).await;
    }
});
Enter fullscreen mode Exit fullscreen mode

This ensures compatibility even with UWP apps that block traditional clipboard listeners! 🛡️

🔌 IPC That Doesn't Suck

The communication between daemon and TUI uses Windows named pipes with a clean JSON protocol:

{
  "type": "Search",
  "query": "error",
  "limit": 50
}
Enter fullscreen mode Exit fullscreen mode

The framing uses 32-bit length prefixes, making it trivial to add new message types while maintaining backwards compatibility. Future-proof by design! 🚀

🎭 Theme System Architecture

The theme system demonstrates Rust's type safety at its finest:

#[derive(Clone, Debug)]
pub struct Theme {
    pub borders: Color,
    pub text: Color,
    pub icons: HashMap<ContentType, Color>,
    pub syntax_highlighting: SyntaxTheme,
}

impl Theme {
    pub fn nord() -> Self { /* Nord theme implementation */ }
    pub fn dracula() -> Self { /* Dracula theme implementation */ }
}
Enter fullscreen mode Exit fullscreen mode

Each theme comprehensively styles borders, text, icons, tags, and syntax highlighting for a cohesive visual experience! 🎨

🚀 Real-World Use Cases & Benefits

💻 Developer Workflow Enhancement

Imagine this scenario: You're debugging a complex issue 🐛:

  1. Copy error message → 📝 Captured!
  2. Copy relevant code snippet → 💻 Captured with syntax highlighting!
  3. Copy API endpoint → 🔗 Captured as URL!
  4. Press F12, type /error, find your context in seconds, paste with Enter

Your flow remains uninterrupted, and you never lose critical debugging context! 🎯

📝 Content Creation & Research

For writers and researchers:

  • Capture quotes, URLs, and references without context switching
  • Use tags (t key) to categorize content by project or topic
  • Export selections as JSON for external processing

🎯 Why It Beats Everything Else

  • Zero Mouse Dependency 🖱️❌: Everything keyboard-driven like a proper power tool
  • Windows-Native Performance ⚡: No Electron bloat, just lean Rust efficiency
  • Process Isolation Reliability 🏗️: UI can restart without losing capture capability
  • Privacy-First Design 🔒: Everything stays local on your machine

🔮 Advanced Features & Customization

🏷️ Smart Tagging System

Organize your clipboard history with a powerful tagging system:

// Add tags to any entry
app.add_tag(current_entry_id, "workflow".to_string());
app.add_tag(current_entry_id, "urgent".to_string());

// Search by tags
app.search("tag:workflow tag:urgent");
Enter fullscreen mode Exit fullscreen mode

Tags render with beautiful colored backgrounds in the UI, making visual scanning a breeze! 🌪️

📊 Metadata-Rich Previews

The preview pane shows more than just content:

Type: 📝 Text
Source: Code.exe
Tags: [rust] [debugging]
Captured: 2 minutes ago
Content: [syntax-highlighted code preview]
Enter fullscreen mode Exit fullscreen mode

This context helps you quickly identify when and why you captured something! 🕵️♂️

🎯 Getting Started (The TL;DR Version)

For detailed setup instructions, see the README.md. The quick version:

git clone https://github.com/surajfale/rusty-clipboard.git
cd rusty-clipboard
.\install.ps1  # Builds, installs, configures F12 hotkey
Enter fullscreen mode Exit fullscreen mode

Restart PowerShell, press F12, and experience clipboard nirvana! 🧘♂️

🚀 The Future Is Bright

The architecture leaves room for exciting extensions:

  • Transformer Pipeline 🔄: Async formatters for JSON prettification, whitespace trimming
  • Sync Capabilities ☁️: Potential OneDrive/DevDrive integration for history backup
  • Plugin System 🧩: Community-driven extensions and themes

💎 Conclusion: Why This Changes Everything

rusty-clipboard isn't just another clipboard manager—it's a philosophy about how terminal tools should work: fast, reliable, keyboard-centric, and beautiful. It respects your workflow while dramatically enhancing your productivity. 🎉

The combination of Rust's performance, Windows-native APIs, and thoughtful UX design creates something truly special. Once you experience the F12 → search → Enter workflow, you'll wonder how you ever worked without it! ✨

Ready to transform your clipboard experience? Star the repo, try it out, and join the conversation about making terminal tools more powerful and delightful! 🌟


rusty-clipboard: Because your clipboard should work for you, not against you. 🎯💪


🔗 Repository: https://github.com/surajfale/rusty-clipboard

🤖 About This Post

This blog post was automatically generated using Auto-Blog-Creator, an AI-powered tool that transforms GitHub repositories into engaging blog content.

🧠 AI Model: deepseek-v3.1:671b-cloud via Ollama Cloud

✨ Key Features:

  • Automated blog generation from GitHub repos
  • AI-powered content creation with advanced prompt engineering
  • Multi-platform support (dev.to, Medium)
  • Smart content parsing and formatting

Interested in automated blog generation? Star and contribute to Auto-Blog-Creator!

Top comments (0)