Skip to content

andersberg/dotfiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dotfiles Manager

A TypeScript-based dotfiles manager for syncing configuration files across macOS machines.

Overview

This tool helps you:

  • Back up dotfiles to a git repository
  • Sync dotfiles across multiple machines
  • Manage symlinks automatically

Installation

Prerequisites

  • Deno 2 (optional, only needed for development)
  • Git

Setup

  1. On your first machine (where you have existing dotfiles):

    # Clone this repo
    git clone <your-repo-url> ~/.dotfiles
    cd ~/.dotfiles
    
    # Copy existing dotfiles and create symlinks
    ./dotfiles copy
    
    # Commit and push
    git add .
    git commit -m "Initial dotfiles backup"
    git push
  2. On additional machines:

    # Clone the repo
    git clone <your-repo-url> ~/.dotfiles
    cd ~/.dotfiles
    
    # Create symlinks to dotfiles
    ./dotfiles link

Usage

Commands

copy

Copies dotfiles from your home directory to ~/.dotfiles and creates symlinks.

./dotfiles copy

Use this for:

  • Initial setup on your first machine
  • Adding new dotfiles to track

link

Creates symlinks from your home directory to files in ~/.dotfiles.

./dotfiles link

Use this for:

  • Setting up a new machine after cloning the repo
  • Restoring symlinks if they get broken

sync

Pulls and pushes changes to/from the git repository.

./dotfiles sync

Use this for:

  • Syncing changes between machines
  • After manually editing dotfiles

Configuration

The managed dotfiles are defined in dotfiles.ts:

const DEFAULT_CONFIG: DotfilesConfig = {
  dotfiles_dir: `${Deno.env.get("HOME")}/.dotfiles`,
  paths: [
    ".gitconfig",
    ".zshrc",
    ".claude",
    ".vscode",
    ".nvm",
  ],
  ignore_patterns: [
    ".DS_Store",
    "node_modules",
    "*.log",
    "cache",
    "tmp",
    "*.swp",
  ],
};

To add more dotfiles, edit the DEFAULT_CONFIG and recompile.

Ignored Patterns

The following patterns are automatically excluded:

  • .DS_Store
  • node_modules
  • *.log
  • cache
  • tmp
  • *.swp

Development

Compiling from Source

If you modify dotfiles.ts, recompile the binary:

deno compile \
  --allow-read \
  --allow-write \
  --allow-run \
  --allow-env \
  --output dotfiles \
  dotfiles.ts

Then commit the updated binary.

Workflow Example

Daily workflow on Machine A:

# Edit your dotfiles normally
vim ~/.zshrc

# Sync when ready
cd ~/.dotfiles
./dotfiles sync

Later on Machine B:

# Pull changes
cd ~/.dotfiles
./dotfiles sync

# Your ~/.zshrc is automatically updated (via symlink)

Troubleshooting

Conflict errors

If you see "Error: file already exists", manually resolve the conflict:

# Check what exists
ls -la ~/.<file>

# Back it up if needed
mv ~/.<file> ~/.<file>.backup

# Try again
./dotfiles link

Broken symlinks

Re-run the link command:

./dotfiles link

Git conflicts

Handle manually:

cd ~/.dotfiles
git status
# resolve conflicts
git add .
git commit
./dotfiles sync

License

MIT

About

My dotfiles.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published