Adding Dotfiles Modules
Checklist
- Create module directory:
modulename/ - Add
README.mdwith:
- Purpose description
- Files table
- Installation command
- Configuration overview
- Customization section
- Add
install.shif needed (see template below) - If the module has an
install.sh, register it in rootinstall.sh, which runs only the modules it sources:
- Add
source "$DOTFILES/modulename/install.sh"among thesourcelines, positioned per the "Order matters" comment above them - Add
bash modulename/install.shto the "Modules" list in the header comment, in the same position
- Add packages to
homebrew/bundleif needed - Update root
README.md:
- Add to "What's Included" if major feature
- Add to "Directory Structure"
- Add to "Module-specific Installation", in the same position as in root
install.sh - Add link to Documentation section
- If new config option:
- Add to
config.sh.examplewith comment - Add to
bash/exports.shto export it - Update
lib/README.mdif new lib function
Install Script Template
#!/usr/bin/env bash
# What this module does
set -euo pipefail
source "$DOTFILES/lib/index.sh"
# Check dependencies (optional)
skip_unless sometool "sometool not installed" || {
symlink "$DOTFILES/mymodule/config" "$HOME/.myconfig"
}
The main install.sh sources each module, so exit in a module ends the whole install and skips every module after it. Guard dependent work with skip_unless <requirement> <message> || { ... }: it prints Skip: <message> and skips the block when the requirement is missing. Keep exit 1 for errors that should stop the install.
- A command:
skip_unless sometool "sometool not installed" || { - An app or other path (contains a slash):
skip_unless "/Applications/Some.app" "Some not installed" || { - Two requirements:
skip_unless brew "Homebrew not installed" || skip_unless php "php not installed" || { - The message is always
<X> not installed, naming only the missing requirement; the helper prefixesSkip: - Anything else (OS, "already installed", a config directory): plain
if/elsewithecho "Skip: ..."
lib/skip.sh holds the full contract.
Testing
# Test standalone
bash mymodule/install.sh --non-interactive --overwrite --allow
# Test via main installer
bash install.sh --non-interactive --overwrite --allow
Reference Modules
git/install.sh— Config + run commandsbash/install.sh— Multiple symlinksnpm/install.sh— Simple symlink onlyssh/install.sh— Permissions + config generation