2014-03-20 22:33:37 -04:00
|
|
|
Dotbot
|
|
|
|
======
|
|
|
|
|
|
|
|
Dotbot is a tool that bootstraps your dotfiles (it's a [Dot]files
|
|
|
|
[bo]o[t]strapper, get it?). It does *less* than you think, because version
|
|
|
|
control systems do more than you think.
|
|
|
|
|
|
|
|
Dotbot is designed to be lightweight and self-contained, with no external
|
|
|
|
dependencies and no installation required. Dotbot is easy to set up, and it's
|
|
|
|
easy to configure.
|
|
|
|
|
|
|
|
Dotbot is VCS-agnostic, and it doesn't make any attempt to manage your
|
2014-10-22 11:10:49 -04:00
|
|
|
dotfiles. Existing version control systems like git are pretty awesome at doing
|
|
|
|
this.
|
2014-03-20 22:33:37 -04:00
|
|
|
|
|
|
|
Dotbot can be a drop-in replacement for any other tool you were using to manage
|
|
|
|
your dotfiles.
|
|
|
|
|
|
|
|
Dotfiles Organization
|
|
|
|
---------------------
|
|
|
|
|
2014-08-19 00:07:24 -04:00
|
|
|
If you want an in-depth tutorial about organizing your dotfiles, see this [blog
|
|
|
|
post][managing-dotfiles-post].
|
|
|
|
|
2014-03-20 22:33:37 -04:00
|
|
|
A great way to organize your dotfiles is having all of them in a single
|
|
|
|
(isolated) git repository and symlinking files into place. You can add plugins
|
|
|
|
and stuff using git submodules. This whole symlinking business can be a bit of
|
2014-10-22 11:10:49 -04:00
|
|
|
work, but it's much better than just having your entire home directory under
|
|
|
|
source control, and Dotbot can automate all of this for you and let you have a
|
|
|
|
one-click install process, so you can have all the benefits of isolation
|
|
|
|
without the annoyance of having to manually copy or link files.
|
2014-03-20 22:33:37 -04:00
|
|
|
|
2014-10-22 11:10:49 -04:00
|
|
|
Dotbot itself is entirely self contained and requires no installation (it's
|
|
|
|
self-bootstrapping), so it's not necessary to install any software before you
|
|
|
|
provision a new machine! All you have to do is download your dotfiles and then
|
|
|
|
run `./install`.
|
2014-03-20 22:33:37 -04:00
|
|
|
|
|
|
|
Template
|
|
|
|
--------
|
|
|
|
|
2014-10-22 11:10:49 -04:00
|
|
|
If you are starting fresh with your dotfiles, you can fork the [template
|
|
|
|
repository][template]. If you want, you can rename it afterwards (to something
|
|
|
|
like just "dotfiles"). If you're looking for inspiration, the template
|
|
|
|
repository contains links to dotfiles repositories that use Dotbot.
|
2014-03-20 22:33:37 -04:00
|
|
|
|
|
|
|
Setup
|
|
|
|
-----
|
|
|
|
|
|
|
|
Dotbot is super easy to set up. This description is given in terms of git and
|
|
|
|
git submodules, but the procedure is similar for other VCSs.
|
|
|
|
|
2014-10-22 11:10:49 -04:00
|
|
|
You can add Dotbot to your dotfiles by running the following command from
|
|
|
|
within your git repository:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
git submodule add https://github.com/anishathalye/dotbot
|
|
|
|
```
|
2014-03-20 22:33:37 -04:00
|
|
|
|
2015-02-12 21:56:38 -05:00
|
|
|
This locks Dotbot on the current version. At any point, to upgrade Dotbot to
|
|
|
|
the latest version, you can run:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
git submodule update --remote dotbot # or other path to Dotbot submodule
|
|
|
|
```
|
|
|
|
|
2014-03-20 22:33:37 -04:00
|
|
|
To have a one-click (one-command) install, you can place a bootstrap install
|
|
|
|
shell script that calls Dotbot with the appropriate parameters. This script
|
|
|
|
simply passes its arguments to Dotbot, so the script itself will not have to be
|
|
|
|
updated once it's placed in the proper location (the Dotbot repository can be
|
|
|
|
updated independently).
|
|
|
|
|
2014-10-22 11:10:49 -04:00
|
|
|
An bootstrap install shell script for git is given in
|
2014-10-27 20:04:00 -04:00
|
|
|
[tools/git-submodule/install][git-install]. By default, the script assumes that
|
|
|
|
the configuration is located in `install.conf.yaml` and Dotbot is located in
|
2014-03-20 22:33:37 -04:00
|
|
|
`dotbot`. The script automatically makes sure that the correct version of
|
|
|
|
Dotbot is checked out in the submodule.
|
|
|
|
|
2014-12-27 15:17:38 -05:00
|
|
|
This script should be **copied** into your dotfiles repository. Once the
|
|
|
|
install script has been copied into your dotfiles, there is no need to modify
|
|
|
|
the script again -- it is merely a shim that checks out the appropriate version
|
|
|
|
of Dotbot and calls the full Dotbot installer. Note that using a symbolic link
|
|
|
|
to the sample install script included in the Dotbot repository won't work
|
|
|
|
correctly -- it can actually lead to several problems. For example, when
|
|
|
|
cloning your dotfiles onto a new system, the Dotbot submodule won't be
|
|
|
|
initialized (unless you use the `--recursive` flag), so the symbolic link will
|
|
|
|
be broken, pointing to a nonexistent file.
|
|
|
|
|
2014-03-20 22:33:37 -04:00
|
|
|
Adapting the bootstrap script for different situations (such as using a
|
|
|
|
different VCS) is fairly straightforward.
|
|
|
|
|
|
|
|
Configuration
|
|
|
|
-------------
|
|
|
|
|
2014-10-27 20:04:00 -04:00
|
|
|
Dotbot uses YAML-formatted (or JSON-formatted) configuration files to let you
|
|
|
|
specify how to set up your dotfiles. Currently, Dotbot knows how to `link`
|
|
|
|
files and folders, execute `shell` commands, and `clean` directories of broken
|
|
|
|
symbolic links.
|
2014-03-20 22:33:37 -04:00
|
|
|
|
|
|
|
**Ideally, bootstrap configurations should be idempotent. That is, the
|
|
|
|
installer should be able to be run multiple times without causing any
|
2014-10-22 11:10:49 -04:00
|
|
|
problems.** This makes a lot of things easier to do (in particular, syncing
|
|
|
|
updates between machines becomes really easy).
|
2014-03-20 22:33:37 -04:00
|
|
|
|
2014-10-27 20:04:00 -04:00
|
|
|
Dotbot configuration files are YAML (or JSON) arrays of tasks, where each task
|
|
|
|
is a dictionary that contains a command name mapping to data for that command.
|
|
|
|
Tasks are run in the order in which they are specified. Commands within a task
|
|
|
|
do not have a defined ordering.
|
2014-10-22 11:10:49 -04:00
|
|
|
|
2015-03-26 22:41:49 -04:00
|
|
|
When writing nested constructs, keep in mind that YAML is whitespace-sensitive.
|
|
|
|
Following the formatting used in the examples is a good idea.
|
|
|
|
|
2014-10-22 11:10:49 -04:00
|
|
|
### Link
|
|
|
|
|
|
|
|
Link commands specify how files and directories should be symbolically linked.
|
2014-10-22 13:27:34 -04:00
|
|
|
If desired, items can be specified to be forcibly linked, overwriting existing
|
|
|
|
files if necessary.
|
2014-10-22 11:10:49 -04:00
|
|
|
|
|
|
|
#### Format
|
|
|
|
|
|
|
|
Link commands are specified as a dictionary mapping targets to source
|
|
|
|
locations. Source locations are specified relative to the base directory (that
|
|
|
|
is specified when running the installer). Source directory names should contain
|
|
|
|
a trailing "/" character.
|
|
|
|
|
2014-10-22 13:27:34 -04:00
|
|
|
Link commands support an (optional) extended configuration. In this type of
|
|
|
|
configuration, instead of specifying source locations directly, targets are
|
|
|
|
mapped to extended configuration dictionaries. These dictionaries map "path" to
|
2014-10-22 14:44:40 -04:00
|
|
|
the source path, specify "create" as true if the parent directory should be
|
|
|
|
created if necessary, and specify "force" as true if the file or directory
|
|
|
|
should be forcibly linked.
|
2014-10-22 13:27:34 -04:00
|
|
|
|
2015-02-10 18:33:37 -05:00
|
|
|
#### Example
|
2014-10-27 20:04:00 -04:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
- link:
|
|
|
|
~/.config/terminator:
|
|
|
|
create: true
|
|
|
|
path: config/terminator/
|
|
|
|
~/.vim: vim/
|
|
|
|
~/.vimrc: vimrc
|
|
|
|
~/.zshrc:
|
|
|
|
force: true
|
|
|
|
path: zshrc
|
|
|
|
```
|
|
|
|
|
2014-10-22 11:10:49 -04:00
|
|
|
### Shell
|
|
|
|
|
|
|
|
Shell commands specify shell commands to be run. Shell commands are run in the
|
|
|
|
base directory (that is specified when running the installer).
|
|
|
|
|
|
|
|
#### Format
|
|
|
|
|
2015-02-03 11:53:05 -05:00
|
|
|
Shell commands can be specified in several different ways. The simplest way is
|
2015-02-05 12:02:02 -05:00
|
|
|
just to specify a command as a string containing the command to be run. Another
|
|
|
|
way is to specify a two element array where the first element is the shell
|
|
|
|
command and the second is an optional human-readable description. Shell
|
2015-02-03 11:53:05 -05:00
|
|
|
commands support an extended syntax as well, which provides more fine-grained
|
|
|
|
control. A command can be specified as a dictionary that contains the command
|
|
|
|
to be run, a description, and whether stdin, stdout, and stderr are enabled. In
|
2015-02-05 12:02:02 -05:00
|
|
|
this syntax, all keys are optional except for the command itself.
|
2014-10-22 11:10:49 -04:00
|
|
|
|
2015-02-10 18:33:37 -05:00
|
|
|
#### Example
|
2014-10-27 20:04:00 -04:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
- shell:
|
2015-02-03 11:53:05 -05:00
|
|
|
- mkdir -p ~/src
|
2014-10-27 20:04:00 -04:00
|
|
|
- [mkdir -p ~/downloads, Creating downloads directory]
|
2015-02-03 11:53:05 -05:00
|
|
|
-
|
|
|
|
command: read var && echo Your variable is $var
|
|
|
|
stdin: true
|
|
|
|
stdout: true
|
|
|
|
-
|
|
|
|
command: read fail
|
|
|
|
stderr: true
|
2014-10-27 20:04:00 -04:00
|
|
|
```
|
|
|
|
|
2014-10-22 11:10:49 -04:00
|
|
|
### Clean
|
|
|
|
|
|
|
|
Clean commands specify directories that should be checked for dead symbolic
|
|
|
|
links. These dead links are removed automatically. Only dead links that point
|
|
|
|
to the dotfiles directory are removed.
|
|
|
|
|
|
|
|
#### Format
|
|
|
|
|
|
|
|
Clean commands are specified as an array of directories to be cleaned.
|
|
|
|
|
2015-02-10 18:33:37 -05:00
|
|
|
#### Example
|
2014-10-27 20:04:00 -04:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
- clean: ['~']
|
|
|
|
```
|
|
|
|
|
2014-10-22 11:10:49 -04:00
|
|
|
### Full Example
|
2014-03-20 22:33:37 -04:00
|
|
|
|
2014-10-22 11:10:49 -04:00
|
|
|
The configuration file format is pretty simple. Here's an example of a complete
|
|
|
|
configuration. The conventional name for the configuration file is
|
2014-10-27 20:04:00 -04:00
|
|
|
`install.conf.yaml`.
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
- clean: ['~']
|
|
|
|
|
|
|
|
- link:
|
|
|
|
~/.dotfiles: ''
|
|
|
|
~/.tmux.conf: tmux.conf
|
|
|
|
~/.vim: vim/
|
|
|
|
~/.vimrc: vimrc
|
|
|
|
|
|
|
|
- shell:
|
2015-02-12 21:41:39 -05:00
|
|
|
- [git submodule update --init --recursive, Installing submodules]
|
2014-10-27 20:04:00 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
The configuration file can also be written in JSON. Here is the JSON equivalent
|
|
|
|
of the YAML configuration given above. The conventional name for this file is
|
2014-10-22 11:10:49 -04:00
|
|
|
`install.conf.json`.
|
2014-03-20 22:33:37 -04:00
|
|
|
|
|
|
|
```json
|
|
|
|
[
|
2014-06-08 14:30:10 -04:00
|
|
|
{
|
|
|
|
"clean": ["~"]
|
|
|
|
},
|
2014-03-20 22:33:37 -04:00
|
|
|
{
|
|
|
|
"link": {
|
2014-10-22 11:10:49 -04:00
|
|
|
"~/.dotfiles": "",
|
2014-03-20 22:33:37 -04:00
|
|
|
"~/.tmux.conf": "tmux.conf",
|
2014-10-27 20:04:00 -04:00
|
|
|
"~/.vim": "vim/",
|
|
|
|
"~/.vimrc": "vimrc"
|
2014-03-20 22:33:37 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"shell": [
|
|
|
|
["git submodule update --init --recursive", "Installing submodules"]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
2014-12-20 00:55:17 -05:00
|
|
|
Contributing
|
|
|
|
------------
|
|
|
|
|
|
|
|
Do you have a feature request, bug report, or patch? Great! See
|
|
|
|
[CONTRIBUTING.md][contributing] for information on what you can do about that.
|
|
|
|
|
2014-03-21 00:48:42 -04:00
|
|
|
License
|
|
|
|
-------
|
|
|
|
|
2015-01-19 19:05:49 -05:00
|
|
|
Copyright (c) 2014-2015 Anish Athalye. Released under the MIT License. See
|
2014-07-22 23:01:54 -04:00
|
|
|
[LICENSE.md][license] for details.
|
2014-03-21 00:48:42 -04:00
|
|
|
|
2014-05-30 10:39:24 -04:00
|
|
|
[template]: https://github.com/anishathalye/dotfiles_template
|
2014-08-03 17:45:18 -04:00
|
|
|
[git-install]: tools/git-submodule/install
|
2014-08-19 00:07:24 -04:00
|
|
|
[managing-dotfiles-post]: http://www.anishathalye.com/2014/08/03/managing-your-dotfiles/
|
2014-12-20 00:55:17 -05:00
|
|
|
[contributing]: CONTRIBUTING.md
|
|
|
|
[license]: LICENSE.md
|