-
Notifications
You must be signed in to change notification settings - Fork 1
Custom Commands
In order to give you as much flexibility as possible, doot
allows you to define custom commands which you can then execute like this:
doot some-command arg1 arg2 ...
Custom commands are shell scripts (or any executable file) located inside <dotfiles_dir>/doot/commands/
. The name of the file must exactly match the command you want to define. Therefore, for the example above, you would create this file: <dotfiles_dir>/doot/commands/some-command
.
Important
Notice how the command files don't include any file extension.
Tip
Make sure the command file has executable permissions set. You can do this by running chmod +x <file>
.
The first non-flag argument passed to doot
will be interpreted as the command name, and any arguments after it will be passed verbatim to your script. For example:
# Runs '<dotfiles_dir>/doot/commands/my-cmd --foo bar'
# Additionally, doot will print extra info due to --verbose
doot --verbose my-cmd --foo bar
The working directory ($PWD
) of the script will be your dotfiles directory, regardless of where the doot
command was run from.
If your command needs to receive relative paths as arguments, you will need to opt out of this behavior by restoring the old PWD. Simply run cd "$ORIGINAL_PWD"
at the start of your script (or use your language's equivalent if it's not a shell script).
If you prefer using Git from the terminal instead of a GUI client, create the following file:
<dotfiles dir>/doot/commands/git
#!/bin/bash
git $@
Now, you can manage your dotfiles repository by running commands like doot git log
and doot git commit
from anywhere in your system.
doot
is not just good for managing your home dotfiles, it can also handle root config files, such as /etc/hosts
or systemd files.
Suppose that, inside your dotfiles directory, you have created a directory called ROOT
which is itself a dotfiles directory with target_dir = "/"
. Create the following file to your outer (non-root) dotfiles directory:
<dotfiles dir>/doot/commands/root
#!/bin/bash
dotfiles_dir="$PWD"
cd "$ORIGINAL_PWD"
sudo DOOT_DIR="$dotfiles_dir/ROOT" doot $@
Now you can manage your root dotfiles by running doot root
, doot root add ...
, etc.