DEV Community

Omar
Omar

Posted on

I built a CLI snippet manager in Rust because I was tired of googling the same things

I have a habit. Every time I sit down to code I end up googling the same thing, how to center a div, the Rust test module boilerplate, docker run flags, ffmpeg commands. Every. Single. Time.

So I built sinbo, a CLI snippet manager that lets you store code once and retrieve it anywhere.

sinbo add docker-run -t docker        # save it once
sinbo get docker-run                  # get it anywhere
sinbo copy docker-run                 # or copy to clipboard
Enter fullscreen mode Exit fullscreen mode

What it does

Snippets are stored locally as plain files in your config directory. No cloud, no account, no sync. Just files you own.

You can tag snippets, add descriptions, and filter by tag:

sinbo add nginx-conf -t infra server -d "default nginx config"
sinbo list -t infra
sinbo search "nginx"
Enter fullscreen mode Exit fullscreen mode

Encryption

The feature I am most proud of, sensitive snippets like API keys and tokens can be encrypted at rest using AES-256-GCM with Argon2id key derivation.

sinbo add github-token --encrypt
sinbo get github-token   # prompts for password
Enter fullscreen mode Exit fullscreen mode

The plaintext never touches disk. Only the .enc file is stored.

Variable placeholders

Snippets can contain placeholders using a custom SINBO:var: syntax:

# snippet content:
docker run -p SINBO:port: -it SINBO:name:

# usage:
sinbo get docker-run -a port=8080 name=myapp
# output: docker run -p 8080 -it myapp
Enter fullscreen mode Exit fullscreen mode

Piping

Since sinbo get prints to stdout it composes naturally with other tools:

sinbo get deploy-script | sh
sinbo get query | psql mydb
sinbo get docker-run -a port=8080 | sh
Enter fullscreen mode Exit fullscreen mode

Shell completions

Tab completion for snippet names works out of the box for bash, zsh, fish and powershell:

echo 'eval "$(sinbo completions bash)"' >> ~/.bashrc && source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

Then sinbo get [TAB] shows your actual snippet names.

What I learned

This was my first time implementing real encryption in Rust. The aes-gcm and argon2 crates made it approachable but I still had to understand the underlying concepts to use them correctly. Building sinbo pushed me to actually learn AES-256-GCM, why nonces matter, and what Argon2id does.

Try it

cargo install sinbo
Enter fullscreen mode Exit fullscreen mode

github: https://github.com/opmr0/sinbo

Would love any feedback or ideas❤️.

Top comments (0)