dotlink

command module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2026 License: GPL-3.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README ΒΆ

A Go utility that scans for dotlink.yaml configuration files and creates symbolic links for configuration management.

Features

✨ Smart Config Parsing

  • YAML-based configuration format
  • Support for directory and file-level linking
  • Environment variable expansion (e.g., $HOME/.zsh)

πŸ”— Flexible Linking

  • Link entire directories to target locations
  • Link individual files with custom target paths
  • Automatic parent directory creation
  • Safe overwriting of existing symlinks

πŸ“Š Enhanced Logging

  • Emoji-based visual feedback
  • Debug-level logging for troubleshooting
  • Information messages for key operations
  • Error handling with clear messages

πŸ§ͺ Comprehensive Testing

  • Full test coverage of core functionality
  • Tests for config parsing, path expansion, and linking
  • Dry-run mode support for safe testing

Configuration Format

Create a dotlink.yaml file in your configuration directory:

link:
  to: $HOME/.zsh

files:
  - file: .zshrc
    to: $HOME/.zshrc
  - file: .zsh_profile
    to: $HOME/.zsh_profile
Configuration Options
  • link.to: Directory where the config directory will be linked
  • files: List of individual files to link
    • file: Path relative to the dotlink.yaml directory
    • to: Target path where the file will be linked (supports environment variables)

Usage

Basic Usage
./dotlink

This will:

  1. Scan $DOTLINK_ROOT (defaults to $HOME/.custom) recursively
  2. Find all dotlink.yaml files
  3. Create symbolic links according to each configuration
Environment Variables
  • DOTLINK_ROOT: Root directory to scan (default: $HOME/.custom)

Implementation Details

Core Components
config.go
  • DotlinkConfig: Main configuration structure
  • LoadConfig(): Parses YAML configuration files
  • ExpandPath(): Expands environment variables in paths
linker.go
  • Linker: Main linking orchestrator
  • LinkDirectory(): Creates directory-level symlinks
  • LinkFile(): Creates file-level symlinks
  • ProcessConfig(): Orchestrates the full linking process
main.go
  • Scans for dotlink.yaml files
  • Iterates and processes each configuration
  • Provides user-friendly emoji-based logging
Logging with Emojis

The tool uses emojis to provide clear visual feedback:

  • πŸ” Scanning operations
  • ✨ Found files
  • πŸ“‚ File system operations
  • πŸ“ Directory linking
  • πŸ“„ File operations
  • πŸ”— Successful links created
  • πŸ“– Config processing
  • βœ… Successful completion
  • ❌ Errors
  • ⚠️ Warnings

Testing

Run the test suite:

go test -v
Test Coverage
  • TestLoadConfig: YAML parsing
  • TestGetConfigDir: Configuration directory extraction
  • TestExpandPath: Environment variable expansion
  • TestLinkerLinkFile: File symlinking
  • TestLinkerLinkDirectory: Directory symlinking
  • TestLinkerDryRun: Dry-run mode verification
  • TestProcessConfig: Full configuration processing
  • TestLoadConfigInvalidYAML: Error handling

Example Workflow

  1. Create a configuration directory structure:

    ~/.custom/zsh/
    β”œβ”€β”€ dotlink.yaml
    β”œβ”€β”€ .zshrc
    └── .zsh_profile
    
  2. Create dotlink.yaml:

    link:
      to: $HOME/.zsh
    files:
      - file: .zshrc
        to: $HOME/.zshrc
      - file: .zsh_profile
        to: $HOME/.zsh_profile
    
  3. Run dotlink:

    DOTLINK_ROOT=$HOME/.custom ./dotlink
    
  4. Result:

    • $HOME/.zsh β†’ symlink to ~/.custom/zsh
    • $HOME/.zshrc β†’ symlink to ~/.custom/zsh/.zshrc
    • $HOME/.zsh_profile β†’ symlink to ~/.custom/zsh/.zsh_profile

Dependencies

  • gopkg.in/yaml.v3: YAML parsing
  • github.com/charmbracelet/log: Enhanced logging with colors and emojis

Building

go build -o dotlink

Error Handling

The tool handles various error conditions gracefully:

  • Missing source files
  • Invalid YAML configuration
  • File system permission issues
  • Existing symlink conflicts

All errors are logged with context to help with troubleshooting.

Documentation ΒΆ

Overview ΒΆ

dotlink is a declarative dotfile symlink manager.

It scans DOTLINK_ROOT (default: $HOME/.custom) for dotlink.yaml manifests and creates symbolic links on your filesystem so that configuration files live in a single version-controlled location and are linked wherever the tools expect them.

Usage ΒΆ

dotlink <command> [flags]

Commands ΒΆ

sync            Create / update all symlinks declared in dotlink.yaml files.
list            Print every dotlink.yaml path found in DOTLINK_ROOT.
status          Show the link status (linked/broken/missing) per target.
config          Print the active runtime configuration.
new [directory] Create a skeleton dotlink.yaml (default: ~/.dotlink).
manual          Print a comprehensive manual with examples.

Environment Variables ΒΆ

DOTLINK_ROOT   Root directory scanned for dotlink.yaml files.
               Defaults to $HOME/.custom.

Examples ΒΆ

dotlink sync
dotlink sync --dry-run
DOTLINK_ROOT=~/dotfiles dotlink sync
dotlink list
dotlink status
dotlink new ~/dotfiles/nvim

Directories ΒΆ

Path Synopsis
Package cmd provides the CLI commands for dotlink.
Package cmd provides the CLI commands for dotlink.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL