DEV Community

ke jia
ke jia

Posted on

Stop Losing Code Snippets: Save, Search, and Copy Them Without Leaving Your Terminal

You know the feeling: you are deep in debugging, you find the perfect one-liner, and then... where does it go?

A new browser tab. A gist. A note in your editor. A TODO.md that slowly becomes a graveyard of half-remembered code.

Three months later you need that exact snippet again. Now the hunt begins: 200 tabs, browser history, "that gist from last year" — and your context on the actual problem is completely gone.

I built SnippetX so that moment never happens again: a code snippet manager that lives where you already are — the terminal.

The One-Liner

No install step, no config, no account. Zero dependencies.

echo 'app.get("/users", handler)' | npx @wuchunjie/snippetx add user-route js
Enter fullscreen mode Exit fullscreen mode
  Saved: "user-route" (js)
Enter fullscreen mode Exit fullscreen mode

That is it. The snippet is stored in ~/.snippetx/snippets.json — a plain JSON file on your machine. No cloud, no account, no tracking.

Find It in 1 Command

npx @wuchunjie/snippetx search route
Enter fullscreen mode Exit fullscreen mode
  🔍  "route" → 1 match

  🔹 a1b2c3d4  user-route
     ...app.get("/users", handler)...
Enter fullscreen mode Exit fullscreen mode

Search matches both the name and the content, case-insensitively. And list gives you the full overview, with optional filtering:

npx @wuchunjie/snippetx list
npx @wuchunjie/snippetx list js
Enter fullscreen mode Exit fullscreen mode
  📋  2 snippets

  🔹 a1b2c3d4  user-route
     lang: js  │  2026-08-22  │  27 chars

  🔹 e5f6a7b8  fetch-user
     lang: py  │  2026-08-22  │  54 chars
Enter fullscreen mode Exit fullscreen mode

Paste It Back Without Leaving the Shell

npx @wuchunjie/snippetx copy a1b2c3d4
Enter fullscreen mode Exit fullscreen mode

copy prints the snippet to stdout, so it chains with whatever you already use:

# macOS / Linux
npx @wuchunjie/snippetx copy a1b2c3d4 | pbcopy
# Windows
npx @wuchunjie/snippetx copy a1b2c3d4 | clip
Enter fullscreen mode Exit fullscreen mode

Or append it straight into a file:

npx @wuchunjie/snippetx copy a1b2c3d4 >> server.js
Enter fullscreen mode Exit fullscreen mode

Why This Beats My Old Workflow

Old way Problem
Browser tab Hundreds of tabs, no metadata, dies with the session
GitHub Gist Login + network required, public by default, slow search
Pastebin Public URLs, no local search, dead-link risk
TODO.md No structure, no language tag, no search
SnippetX Instant, local, language-tagged, private

Your snippets are a single JSON file. Want them on every machine? git init the folder, done. Want a backup? One file to copy. You own your data — that is the whole point.

The Full Command Set

add  <name> [lang]     Save snippet (pipe content in)
list [filter]          List all snippets
show <id>              View a snippet
search <term>          Search all snippets
rm <id>                Delete a snippet
copy <id>              Output snippet to stdout
Enter fullscreen mode Exit fullscreen mode

Try It Now

echo 'console.log("I never lose code again")' | npx @wuchunjie/snippetx add first js
npx @wuchunjie/snippetx list
Enter fullscreen mode Exit fullscreen mode

npm: @wuchunjie/snippetx | GitHub: wuchunjie00/devtools


From the same toolbox

  • ScaffoldX — generate 12 production-ready project templates in seconds: npx scaffoldx-cli
  • DotGuard — scan .env files for exposed secrets: npx @wuchunjie/dotguard
  • GitPulse — git analytics (commits, contributors, activity) in your terminal: npx @wuchunjie/gitpulse

☕ If This Saved You Time

SnippetX is and will always be 100% free. If it makes your day a little easier, consider fueling the next tool:

Buy me a coffee on Ko-fi

Built with ❤️. Zero dependencies, zero tracking, zero bloat.

Top comments (0)