yadm(1) | General Commands Manual | yadm(1) |
yadm - Yet Another Dotfiles Manager
yadm command [options]
yadm git-command-or-alias [options]
yadm init [-f] [-w directory]
yadm clone url [-f] [-w directory] [--bootstrap] [--no-bootstrap]
yadm config name [value]
yadm config [-e]
yadm list [-a]
yadm bootstrap
yadm encrypt
yadm enter
yadm decrypt [-l]
yadm alt
yadm perms
yadm introspect category
yadm is a tool for managing a collection of files across multiple computers, using a shared Git repository. In addition, yadm provides a feature to select alternate versions of files based on the operating system or host name. Lastly, yadm supplies the ability to manage a subset of secure files, which are encrypted before they are included in the repository.
Dotfiles are managed by using standard git commands; add, commit, push, pull, etc.
The config command is not passed directly through. Instead use the gitconfig command (see below).
You can review the stashed conflicts by running the command
from within your $HOME directory. If you want to restore the stashed data, you can run
The repository is stored in $HOME/.yadm/repo.git. By default, $HOME will be used as the work-tree, but this can be overridden with the -w option. yadm can be forced to overwrite an existing repository by providing the -f option. By default yadm will ask the user if the bootstrap program should be run (if it exists). The options --bootstrap or --no-bootstrap will either force the bootstrap to be run, or prevent it from being run, without prompting the user.
yadm supports a set of universal options that alter the paths it uses. The default paths are documented in the FILES section. Any path specified by these options must be fully qualified. If you always want to override one or more of these paths, it may be useful to create an alias for the yadm command. For example, the following alias could be used to override the repository directory.
The following is the full list of universal options. Each option should be followed by a fully qualified path.
yadm uses a configuration file named $HOME/.yadm/config. This file uses the same format as git-config(1). Also, you can control the contents of the configuration file via the yadm config command (which works exactly like git-config). For example, to disable alternates you can run the command:
The following is the full list of supported configurations:
When managing a set of files across different systems, it can be useful to have an automated way of choosing an alternate version of a file for a different operating system, host, or user. yadm implements a feature which will automatically create a symbolic link to the appropriate version of a file, as long as you follow a specific naming convention. yadm can detect files with names ending in any of the following:
##
##CLASS
##CLASS.OS
##CLASS.OS.HOSTNAME
##CLASS.OS.HOSTNAME.USER
##OS
##OS.HOSTNAME
##OS.HOSTNAME.USER
If there are any files managed by yadm´s repository, or listed in $HOME/.yadm/encrypt, which match this naming convention, symbolic links will be created for the most appropriate version. This may best be demonstrated by example. Assume the following files are managed by yadm´s repository:
- $HOME/path/example.txt##
- $HOME/path/example.txt##Work
- $HOME/path/example.txt##Darwin
- $HOME/path/example.txt##Darwin.host1
- $HOME/path/example.txt##Darwin.host2
- $HOME/path/example.txt##Linux
- $HOME/path/example.txt##Linux.host1
- $HOME/path/example.txt##Linux.host2
If running on a Macbook named "host2", yadm will create a symbolic link which looks like this:
$HOME/path/example.txt -> $HOME/path/example.txt##Darwin.host2
However, on another Mackbook named "host3", yadm will create a symbolic link which looks like this:
$HOME/path/example.txt -> $HOME/path/example.txt##Darwin
Since the hostname doesn't match any of the managed files, the more generic version is chosen.
If running on a Linux server named "host4", the link will be:
$HOME/path/example.txt -> $HOME/path/example.txt##Linux
If running on a Solaris server, the link use the default "##" version:
$HOME/path/example.txt -> $HOME/path/example.txt##
If running on a system, with CLASS set to "Work", the link will be:
$HOME/path/example.txt -> $HOME/path/example.txt##WORK
If no "##" version exists and no files match the current CLASS/OS/HOSTNAME/USER, then no link will be created.
Links are also created for directories named this way, as long as they have at least one yadm managed file within them.
CLASS must be manually set using yadm config local.class <class>. OS is determined by running uname -s, HOSTNAME by running hostname, and USER by running id -u -n. yadm will automatically create these links by default. This can be disabled using the yadm.auto-alt configuration. Even if disabled, links can be manually created by running yadm alt.
It is possible to use "%" as a "wildcard" in place of CLASS, OS, HOSTNAME, or USER. For example, The following file could be linked for any host when the user is "harvey".
$HOME/path/example.txt##%.%.harvey
CLASS is a special value which is stored locally on each host (inside the local repository). To use alternate symlinks using CLASS, you must set the value of class using the configuration local.class. This is set like any other yadm configuration with the yadm config command. The following sets the CLASS to be "Work".
yadm config local.class Work
Similarly, the values of OS, HOSTNAME, and USER can be manually overridden using the configuration options local.os, local.hostname, and local.user.
If the envtpl command is available, Jinja templates will also be processed to create or overwrite real files. yadm will treat files ending in
##yadm.j2
as Jinja templates. During processing, the following variables are set according to the rules explained in the ALTERNATES section:
YADM_CLASS
YADM_OS
YADM_HOSTNAME
YADM_USER
In addition YADM_DISTRO is exposed as the value of lsb_release -si if lsb_release is locally available.
For example, a file named whatever##yadm.j2 with the following content
{% if YADM_USER == 'harvey' -%}
config={{YADM_CLASS}}-{{ YADM_OS }}
{% else -%}
config=dev-whatever
{% endif -%}
would output a file named whatever with the following content if the user is "harvey":
config=work-Linux
and the following otherwise:
config=dev-whatever
See http://jinja.pocoo.org/ for an overview of Jinja.
It can be useful to manage confidential files, like SSH or GPG keys, across multiple systems. However, doing so would put plain text data into a Git repository, which often resides on a public system. yadm implements a feature which can make it easy to encrypt and decrypt a set of files so the encrypted version can be maintained in the Git repository. This feature will only work if the gpg(1) command is available.
To use this feature, a list of patterns must be created and saved as $HOME/.yadm/encrypt. This list of patterns should be relative to the configured work-tree (usually $HOME). For example:
Standard filename expansions (*, ?, [) are supported. Other shell expansions like brace and tilde are not supported. Spaces in paths are supported, and should not be quoted. If a directory is specified, its contents will be included, but not recursively. Paths beginning with a "!" will be excluded.
The yadm encrypt command will find all files matching the patterns, and prompt for a password. Once a password has confirmed, the matching files will be encrypted and saved as $HOME/.yadm/files.gpg. The patterns and files.gpg should be added to the yadm repository so they are available across multiple systems.
To decrypt these files later, or on another system run yadm decrypt and provide the correct password. After files are decrypted, permissions are automatically updated as described in the PERMISSIONS section.
Symmetric encryption is used by default, but asymmetric encryption may be enabled using the yadm.gpg-recipient configuration.
NOTE: It is recommended that you use a private repository when keeping confidential files, even though they are encrypted.
When files are checked out of a Git repository, their initial permissions are dependent upon the user's umask. Because of this, yadm will automatically update the permissions of some file paths. The "group" and "others" permissions will be removed from the following files:
- $HOME/.yadm/files.gpg
- All files matching patterns in $HOME/.yadm/encrypt
- The SSH directory and files, .ssh/*
- The GPG directory and files, .gnupg/*
yadm will automatically update permissions by default. This can be disabled using the yadm.auto-perms configuration. Even if disabled, permissions can be manually updated by running yadm perms. The .ssh directory processing can be disabled using the yadm.ssh-perms configuration. The .gnupg directory processing can be disabled using the yadm.gpg-perms configuration.
When cloning a repo which includes data in a .ssh or .gnupg directory, if those directories do not exist at the time of cloning, yadm will create the directories with mask 0700 prior to merging the fetched data into the work-tree.
When running a Git command and .ssh or .gnupg directories do not exist, yadm will create those directories with mask 0700 prior to running the Git command. This can be disabled using the yadm.auto-private-dirs configuration.
For every command yadm supports, a program can be provided to run before or after that command. These are referred to as "hooks". yadm looks for hooks in the directory $HOME/.yadm/hooks. Each hook is named using a prefix of pre_ or post_, followed by the command which should trigger the hook. For example, to create a hook which is run after every yadm pull command, create a hook named post_pull. Hooks must have the executable file permission set.
If a pre_ hook is defined, and the hook terminates with a non-zero exit status, yadm will refuse to run the yadm command. For example, if a pre_commit hook is defined, but that command ends with a non-zero exit status, the yadm commit will never be run. This allows one to "short-circuit" any operation using a pre_ hook.
Hooks have the following environment variables available to them at runtime:
The following are the default paths yadm uses for its own data. These paths can be altered using universal options. See the OPTIONS section for details.
Report issues or create pull requests at GitHub:
https://github.com/TheLocehiliosan/yadm/issues
Tim Byrne <sultan@locehilios.com>
https://thelocehiliosan.github.io/yadm/
25 October 2017 | 1.12.0 |