A plugin for conditional execution of Dotbot directives based on the hostname of the machine.
Inspired by dotbot-if and dotbot-ifplatform.
This is a plugin for Dotbot, requiring it to be available.
- Add dotbot-ifhostname as a submodule to your dotfiles repository:
git submodule add https://github.com/johnlettman/dotbot-ifhostname.git
- Pass the CLI argument
--plugin-dir path/to/dotbot-ifhostname
when executing thedotbot
command.
Add the ifhostname
directive to the Dotbot YAML configuration file
to conditionally execute the directives:
- ifhostname:
hostname: computer-a
met:
- shell:
- echo on computer A!
- ifhostname:
hostname: computer-b
met:
- shell:
- echo on computer B!
unmet:
- shell:
- echo this isn't computer B!
The following configuration options are available for the ifhostname
directive:
Option | Required | Description |
---|---|---|
hostname |
Yes | The hostname to match against. |
met |
No | Directives to execute when the hostname matches. |
unmet |
No | Directives to execute when the hostname does not match. |