Skip to main content

A safe editing wrapper: edits a temp copy, compares, and saves original backup if changed.

Project description

mirro

mirro is a tiny safety-first editing wrapper for text files. You edit a temporary file, mirro detects whether anything changed, and if it did, it saves a backup of the original before writing your changes.

Why mirro?

Well... have you ever been in the “ugh, I forgot to back this up first” situation?

No?

Stop lying... 🥸

mirro gives you a built-in safety net:

  • never edits the real file directly

  • detects whether the edit actually changed content

  • creates a timestamped backup only when changes occurred

  • clearly labels backups so you know exactly what they came from

  • respects the user’s $EDITOR when possible

  • requires sudo only when actually needed

  • accepts most of your favourite editor's flags

It’s simple, predictable, and hard to misuse.

I mean... the only thing you need to remember is to use it.

How it works

mirro reads the original file (or pre-populates new files with a friendly message).

It writes that content into a temporary file.

It launches your $EDITOR to edit the temp file.

When the editor closes, mirro compares old vs new.

If nothing changed:

file hasn't changed

If changed:

file changed; original backed up at: ~/.local/share/mirro/ (or /root/.local/share/mirro/ under sudo)

Backed up files include a header:

# ---------------------------------------------
# mirro backup
# Original file: /path/to/whatever.conf
# Timestamp: 2025-11-10 17:44:00 UTC
# ---------------------------------------------

So you never lose track of the original location.

Backup directory

By default all the backups will be stored at:

~/.local/share/mirro/

so under sudo:

/root/.local/share/mirro/

Backups are named like:

filename.ext.orig.20251110T174400.bak

Installation

NOTE: To use mirro with sudo, the path to mirro must be in the $PATH seen by root.
Either:

  • install mirro as root (preferred), or
  • add the path to mirro to the secure_path parameter in /etc/sudoers. For example, where /home/user/.local/bin is where mirro is:
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/user/.local/bin"

Install via PyPI (preferred):

pip install mirro

Or clone the repo and install locally:

git clone https://github.com/mdaleo404/mirro.git
cd mirro/
poetry install

How to run the tests

  • Clone this repository

  • Ensure you have Poetry installed

  • Run poetry run pytest -vvvv --cov=mirro --cov-report=term-missing --disable-warnings

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mirro-0.2.0.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mirro-0.2.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file mirro-0.2.0.tar.gz.

File metadata

  • Download URL: mirro-0.2.0.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.9 Linux/6.17.7-200.fc42.x86_64

File hashes

Hashes for mirro-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dd776140266f81b6f7531bfc5e25d50c670235e63ab8d174b1d4e6dd755f4ac8
MD5 f139d3823c3d6ec5abb1e8acb59a13c1
BLAKE2b-256 1a61db2ce8b1c8fcc1542906d04f83d0864c6b0526fd5b2ffeca8f7deeb46d5f

See more details on using hashes here.

File details

Details for the file mirro-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mirro-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.13.9 Linux/6.17.7-200.fc42.x86_64

File hashes

Hashes for mirro-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d3932796ddd18638fcd491ce95e47e8e8b14ed6128cd3996595f3eaf37c7aa6
MD5 9047b19da3e8c4a0227d7f75582ee165
BLAKE2b-256 73e5eb832a589b801cb582f741b664e2c0706835dbf36752b1d3648bffc11669

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page