-
Notifications
You must be signed in to change notification settings - Fork 1
Hooks
You can extend the functionality of doot
by defining custom hooks to be run at different stages of execution.
Hooks are shell scripts (or any executable file) located inside <dotfiles_dir>/doot/hooks/<hook_name>/
. When a given condition is met, all files inside the corresponding hook directory are executed sequentially, in alphabetical order. If you need your hooks to run in a specific order, I recommend adding a number prefix (01.prepare-files.sh
, 02.other-actions.sh
, ...).
A hook can abort the execution by returning a non-zero exit code. The other files in the hook directory will not be executed, and doot
will exit immediately.
Tip
The working directory ($PWD
) of the executed scripts will always be the dotfiles repository, regardless of where the doot
command was executed from.
Warning
If your hooks are shell scripts, make sure to add the appropriate shebang (for example, #!/bin/bash
). Otherwise the file will be intepreted as a binary and the hook will fail with the message "exec format error".
Additionally, make sure the hook file has executable permissions set. You can do this by running chmod +x <file>
.
-
doot/hooks/before-update/*
: Before the dotfiles directory is scanned for changes. Affectsinstall
,clean
andbootstrap
commands (see lifecycles below). -
doot/hooks/after-update/*
: After the symlinks have been created or removed. Affectsinstall
,clean
andbootstrap
commands (see lifecycles below). -
doot/hooks/before-bootstrap/*
: After the dotfiles repository has been cloned, before it is installed. -
doot/hooks/after-bootstrap/*
: After the bootstrap process. This is a good place to install packages and enable services.
Install:
- Run
before-update
hooks. - Scan the dotfiles directory for changes.
- Create and delete symlinks.
- Run
after-update
hooks.
Clean:
- Run
before-update
hooks. - Delete symlinks.
- Run
after-update
hooks.
Bootstrap:
- Clone dotfiles repository.
- Unlock private files with decryption key (if applicable).
- Run
before-bootstrap
hooks. - Run
before-update
hooks. - Scan the dotfiles directory for links to be created.
- Create symlinks.
- Run
after-update
hooks. - Run
after-bootstrap
hooks.