A plugin for dotbot that provides file copying functionality.
This plugin is designed for scenarios where you need to copy configuration files instead of creating symbolic links. It's particularly useful when you have example configuration files in your dotfiles repository that need to be copied to different machines, where each machine may require its own local modifications. Unlike dotbot's built-in linking functionality, this plugin creates actual copies of the files, allowing for machine-specific customizations while maintaining the original example files in your dotfiles repository.
The plugin includes several safety measures to prevent accidental file operations:
-
Home Directory Restriction: All operations are restricted to the user's home directory. Any attempts to copy files outside the home directory will be blocked.
-
Overwrite Protection: By default, existing files are never overwritten. The
overwrite
option must be explicitly set totrue
to allow overwriting files. -
Directory Safety: When copying directories, the plugin checks for existing files in the destination to prevent accidental overwrites of any files within the directory structure.
-
Parent Directory Control: The
create
option controls whether parent directories should be created. When set tofalse
(default), the plugin will fail if parent directories don't exist, preventing accidental directory creation.
Add the plugin as a submodule to your dotfiles repo:
git submodule add https://github.com/jelleh/dotbot-copy.git
Execute dotbot
with plugin parameter:
./install -p dotbot-copy/copy.py
All configuration parameters can be specified either globally in defaults
task or locally for each individual record.
Example containing all options enumerated with their default values:
- defaults:
copy:
overwrite: false # Whether to overwrite existing files
create: false # Whether to create parent directories as needed
- copy:
~/.config/myapp/config.json:
path: config/myapp/config.json
overwrite: true # Override global default for this file
create: true # Create parent directories for this file
~/.local/share/myapp/data:
path: local/share/myapp/data
overwrite: false # Use global default
create: false # Use global default
You can also use a simpler format for files that don't need the overwrite option:
- copy:
~/.config/myapp/config.json: config/myapp/config.json
If the source location is omitted or set to null, the plugin will use the basename of the destination, with a leading . stripped if present. This makes the following two configurations equivalent:
- copy:
~/.vimrc: vimrc
~/.vimrc:
path: vimrc
MIT License