snip-stitch
Idempotently add, update, or remove managed snippets inside shell-like text files.
Installers love to append lines to your shell profile. Uninstallers… don’t.
snip-stitch fixes this by wrapping each snippet in marker lines, so future runs can find, update, or cleanly remove exactly that section – and leave everything else alone.
# ---8<- nvm -- managed section, avoid editing export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # -8<--- nvm --
No dependencies. Idempotent by design. One file, one job.
Installation
Run directly (no install required):
uvx snip-stitch --help
It can also be pip-installed, or ran ad-hoc (it uses std lib only).
Commands
Every invocation follows the same shape:
snip-stitch [options] <command> <tag> <target> [content]
tag – identifies the managed section (3-32 lowercase chars: [a-z][a-z0-9._-]{2,31})
target – the file to modify (e.g. ~/.bashrc, ~/.ssh/config)
content – the snippet source (meaning depends on the command)
text – inline snippet
Pass the snippet directly as a string. Handy for one-liners:
snip-stitch text rustup ~/.profile \ '[ -f "$HOME/.cargo/env" ] && . "$HOME/.cargo/env"'
Supports \n escapes for callers that cannot easily pass literal newlines.
file – snippet from a file
Read the snippet from a file on disk. Useful when the snippet is maintained separately or generated by another tool:
snip-stitch file sdkman ~/.bashrc sdkman-init.sh
snip-stitch file personal-github ~/.ssh/config personal-git.config
remove – delete a managed section
Remove a previously managed section by its tag. Only two arguments needed:
snip-stitch remove sdkman ~/.bashrc
The surrounding file content is left untouched.
Options
Options go before the command:
snip-stitch -n --force text mytag ~/.bashrc 'echo hello'
-n, --dryrun |
Show what would happen without modifying the file |
-v, --verbose |
Print extra detail to stderr |
-f, --force |
Rewrite even if the managed section hasn’t changed |
--comment-chars |
Comment character(s) for the target file (default: #) |
--start-comment |
Comment appended to the opening marker line |
--end-comment |
Comment appended to the closing marker line |
--snip-marker |
Marker string (default: -8<-) |
How it works
Given this command:
snip-stitch file nvm ~/.zshrc nvm-init.sh
The target file will contain:
# ---8<- nvm -- managed section, avoid editing export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # -8<--- nvm --
Run it again with the same content? Nothing happens – the file is not rewritten. Change the content? Only the managed section is updated in place. Use remove? The markers and everything between them are deleted, the rest stays put.
Use cases
Shell installers – tools like nvm, sdkman, rustup, and Homebrew need to inject initialization lines into shell profiles. Instead of grep ... || echo ... >> ~/.zshrc (and hoping for the best at uninstall time), use snip-stitch for clean ownership.
Dotfile managers – keep your ~/.bashrc, ~/.zprofile, or ~/.ssh/config tidy by giving each concern its own tagged section.
CI/CD and automation – any setup script that needs to own a section of a config file without clobbering the rest of it.
Package managers – npm, Homebrew, and similar tools that modify shell config during install can use the same tag at uninstall time to cleanly remove their section.
Guarantees
Same input produces same file contents (idempotent)
Unchanged snippet content does not rewrite the file
Removal leaves surrounding content intact
Zero runtime dependencies
Metadata
Release files for snip-stitch 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| snip_stitch-1.0.2.tar.gz | 10.4 kB | With provenance | Details for snip_stitch-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| snip_stitch-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for snip_stitch-1.0.2-py3-none-any.whl |
Total release size: 17.6 kB
Release files / snip_stitch-1.0.2.tar.gz
| Download URL | snip_stitch-1.0.2.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
422d4e34b20ff328b821d5e2c7cc9d8580f0b529363fdc181a0ec99d8c3d9e02
|
|
BLAKE2b-256 checksum How to use checksums |
7445911257c9f0276234497eae099c6ec00c6982f7ae70deb8ee0a251570542b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 2, 2026.
Transparency logRelease files / snip_stitch-1.0.2-py3-none-any.whl
| Download URL | snip_stitch-1.0.2-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3de269a60f80c8c3fda76e6fd30f25c43a5af9aeafc05f93027bce273a694fb2
|
|
BLAKE2b-256 checksum How to use checksums |
8f4916f0c7b2a3284426fca0a140987ff9037ddc8bdacd696a58b77026512c5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 2, 2026.
Transparency logSecurity for snip-stitch 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for snip_stitch-1.0.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 2, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.