The problem it solves
On a developer Mac, a large share of what gets backed up has no lasting value: node_modules directories, Python virtual environments, compiler caches, Xcode derived data, downloaded models… All of that can be re-downloaded or rebuilt. Backing it up slows Time Machine down, fills the backup disk, and buries the files that actually matter.
Excluding these folders by hand is tedious and risky: they reappear in every new project, and an exclusion that is too broad can drop unique data (virtual machines, local databases, tool sessions). tm-exclusions automates this sorting in a way that is predictable, reversible and verifiable.
Preview
Dry-run mode shows what would be excluded, without adding or removing Time Machine exclusions. A report is still saved (or overwritten).
Apply safely
Idempotent: running it again only does what is still needed.
Protect
A keep rule prevents a path from being excluded, even by a parent directory.
Undo
Uninstall mode removes the exclusions that match the configured rules.
Architecture
A single script, organised as a sequence of steps. Rules are described in plain text files in the type|target|reason format; the code contains no hard-coded path lists.
- Merged configuration: the catalog shipped with the tool, then personal rules, then an optional extra file. Preferences follow a last-value-wins rule, rules are added together, and a keep rule always takes precedence.
- Five rule types:
path(a specific path),pattern(a directory name searched under the home folder),prune(a zone whose scan results are ignored),keep(protection) andsetting(a preference). - Two-phase scan: collect every match, then sort and process, for a deterministic result and a grouped display.
- Dual exclusion strategy: a directory-attached exclusion for paths the user can write (including outside the home folder), and a fixed-path exclusion with privilege elevation for other system paths.
Design choices, and why
Bash 3.2, no dependencies
This is the shell that ships with macOS: the tool runs on a new machine, with nothing else to install. The trade-off is accepted: no Bash 4 features (associative arrays, and so on).
Configuration rather than code
Adding an ecosystem means adding a commented line. A dedicated syntax checker validates the rule files in continuous integration.
Cautious by default
Mixed folders (Docker data, virtual machines, archives, agent sessions) ship disabled: the user has to turn them on explicitly.
tmutil abstraction layer
Three functions wrap every Time Machine call. Off macOS, they simulate the behaviour: the test suite runs under Linux without touching any backup.
Fail explicitly
An unknown exclusion status never authorises an add or a removal. Any error, incomplete scan or protection conflict produces a non-zero exit code.
Bilingual French / English
Messages live in separate translation tables, whose key parity is checked automatically.
Skills demonstrated
- Robust, portable shell scripting: strict mode, systematic quoting, signal handling and temporary-file cleanup, ShellCheck static analysis.
- Data-safety-oriented design: keep rules take priority, symbolic links are resolved, ambiguous paths are refused, and reports trace back to the source configuration line.
- Automated tests: several suites (end-to-end behaviour, safety, release logic, validators, categories) run on every change.
- Continuous integration and delivery: GitHub Actions with SHA-pinned actions, dependency review, version publishing, and automatic updates of a Homebrew formula.
- Repository tooling and quality: Git hooks that enforce conventional commit messages, automatic issue labelling and triage, a changelog kept up to date.
- Terminal user experience: grouped display, progress bars, colours turned off automatically outside an interactive terminal, and a quiet mode for scheduled runs.
Measurable results
- 454automated checks passed, across 6 suites
- 115active rules in the bundled catalog
- 17documented categories (Node.js, Python, Rust, Xcode…)
- 6published versions (1.0.0, 1.2.0, 1.3.0, 1.4.0, 1.4.1, 1.4.2)
Sources: last continuous-integration run on the main branch (commit 4f7def9, 0 failures); count of uncommented path, pattern and prune lines in config/default.conf; categories listed in the README; versions: GitHub Releases, latest v1.4.2. Space saved depends on each machine and is not quantified here.
Known limits
- macOS only: elsewhere, operations are only simulated.
- The dynamic scan is deliberately limited to a depth of 6 directories; ignored zones filter the results but do not shorten the walk.
- Displayed sizes are estimates of disk usage, not a guarantee of backup savings (hard links, APFS clones).
- A keep rule added after the fact does not remove an existing exclusion: the conflict is reported and has to be cleared by hand.
- System paths the user cannot write require administrator rights; without them, they are counted as blocked and the run exits with an error.
- Most exclusions do not appear in System Settings; they are checked from the command line.
- Disk-image discovery is off by default and capped at 50 items per run.
Credits
- Time Machine and its command-line utility
tmutil, provided by Apple with macOS. - ShellCheck, the static analyser used in continuous integration.
- Homebrew for distribution, Shields.io for the badges, and Icons8 for the README icon.