https://github.com/en9inerd/sdfm
Simple DotFiles Manager
https://github.com/en9inerd/sdfm
bash bash-script cli dotfiles script
Last synced: about 1 month ago
JSON representation
Simple DotFiles Manager
- Host: GitHub
- URL: https://github.com/en9inerd/sdfm
- Owner: en9inerd
- License: mit
- Created: 2025-05-30T00:35:28.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-10-05T23:18:53.000Z (9 months ago)
- Last Synced: 2025-10-06T01:12:59.675Z (9 months ago)
- Topics: bash, bash-script, cli, dotfiles, script
- Language: Shell
- Homepage:
- Size: 68.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sdfm - Simple DotFiles Manager
A lightweight Bash tool for managing your dotfiles in a Git repository with easy backup and environment switching.
---
## Features
- Initialize or clone a dotfiles repository
- Track files and directories under `$HOME`
- Create and switch between environments (branches)
- Backup existing files before applying new ones
- Tag and version your configurations
- Synchronize with remote
- Minimal dependencies (Bash, Git, rsync)
---
## Installation
You can install **sdfm** automatically with the provided `install.sh` script:
```bash
curl -fsSL https://raw.githubusercontent.com/en9inerd/sdfm/master/install.sh | bash
```
## Usage
```bash
sdfm [options]
```
Run `sdfm help` for a full command list:
```
Repository Setup:
init --remote [--branch ] Initialize dotfiles repo
clone [--branch ] Clone remote repo
create-empty-branch Create new empty orphan branch
Environment Management:
switch Switch to environment (Git branch)
copy Create and switch to a new branch
sync [--force] [--dry-run] Sync with remote (requires --force)
pull [--merge] Pull from remote (fast-forward default)
push Push current branch
tag Create and push a tag
list-tags List tags
checkout-tag Checkout a tag
File Tracking:
add ... Copy file(s) from $HOME to repo
rm ... Remove file(s) from repo
list List tracked files
update [--dry-run] Update tracked files from $HOME
status Show status
log Show log
diff Show differences between $HOME and repo
apply [--dry-run] Backup and apply dotfiles to $HOME
Backup Maintenance:
list-backups List available backups
restore Restore files from a backup
cleanup-backup [--keep-days ] [--dry-run] Delete old backups (default: 30 days)
Other:
git Run arbitrary git command in repo
help Show this help
```
## Example Workflow
1. Initialize a new repository
```bash
sdfm init --remote git@github.com:yourname/dotfiles.git --branch main
```
2. Add and commit dotfiles
```bash
sdfm add ~/.bashrc ~/.vimrc ~/.config/nvim
```
3. Push changes
```bash
sdfm push
```
4. Apply configuration
This backs up current files before overwriting them:
```bash
sdfm apply
```
5. Switch environments
Create a new branch:
```bash
sdfm copy work-env
```
Switch to it:
```bash
sdfm switch work-env
```
6. Sync with remote
```bash
sdfm sync --force
```
7. Tag configuration
```bash
sdfm tag initial-setup
```
List tags:
```bash
sdfm list-tags
```
Checkout a tagged version:
```bash
sdfm checkout-tag initial-setup
```
## Backups
Every `apply` creates a backup in:
```bash
$HOME/.local/share/sdfm/backups/
```
List available backups:
```bash
sdfm list-backups
```
Restore from a backup:
```bash
sdfm restore 20260201143022
```
Clean up old backups (older than 30 days by default):
```bash
sdfm cleanup-backup
sdfm cleanup-backup --keep-days 7
sdfm cleanup-backup --dry-run # Preview what would be deleted
```
## Dry-Run Mode
Preview changes before applying them:
```bash
sdfm apply --dry-run # See what files would be overwritten
sdfm update --dry-run # See what files would be updated in repo
sdfm sync --dry-run # See what local changes would be discarded
```
## Safety Features
- **Sensitive file warnings**: Adding files matching patterns like `.ssh/id_*`, `.env`, `*credentials*` will prompt for confirmation
- **Sync protection**: `sync` requires `--force` flag if there are local changes to discard
- **Automatic backups**: Every `apply` backs up existing files first
## Requirements
- Bash
- Git
- rsync
## License
MIT