Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
So far so good. But we use vim, tmux, tmuxinator, zsh, newsbeuter, mutt... a lot of dotfiles, a lot of castles, a little mess... Why don't we create a one single castle with all of our dotfiles? For some people it can be a reasonable option, but, in general, having them organized has some advantages:
You can keep different configurations for the same application. A ssh at home and another at work.
You can keep public the dotfiles you would like to share with the community (vim) and private the ones you don't want to (mutt).
You can pick which castles you would like to recover. Maybe you don't want newsbeuter at work.
Here it is when the other star comes in. It is myrepos, a tool that allows you to work with a lot of repositories at once. With it, you can push, pull, commit and other operations at the same time in a set of registered repositories.
Installing it is again very easy. It has a self-contained
mr executable which only dependency is perl. You can have more details in its homepage. Once done, you can run
mr help to know about the bunch of magic you can do with it.
Let's see a possible workflow for our dotfiles. Imagine we have just two castles,
mr needs that repositories to exist in your filesystem and to already have a remote registered.
homeshick cd vim-castle # Enter your vim castle mr register # Register it to mr homeshick cd tmux-castle # Enter your tmux castle mr register # Register it to mr
Once done the above, you should have a
~/.mrconfig file with something like the following:
[.homesick/repos/vim-castle] checkout = git clone 'email@example.com:username/vim-castle.git' 'vim-castle' [.homesick/repos/tmux-castle] checkout = git clone 'firstname.lastname@example.org:username/tmux-castle.git' 'tmux-castle'
Between the square brackets
 there are the local filesystem locations for the repositories (relative to
home; that source is the default homeshick location), and the value for the
checkout option is the command that
mr will run to checkout your repositories.
Using it with homeshick, even if no mandatory, it is a good idea to change that checkout command to
homeshick clone, which will automatically create the symlinks in the actual
home directory. So, the
.mrconfig file would look like this:
[.homesick/repos/vim-castle] checkout = homeshick clone 'email@example.com:username/vim-castle.git' 'vim-castle' [.homesick/repos/tmux-castle] checkout = homeshick clone 'firstname.lastname@example.org:username/tmux-castle.git' 'tmux-castle'
In fact, it is a good idea to make another castle with your
.mrconfig file, because when you migrate to a new system, you have to get it again and run:
mr checkout # Checkout all the repositories in one single command
Instead, you could also run
mr bootstrap <url>, where
<url> is pointing to an URL where it is the mrconfig file.
mr the options are almost countless. You can run
mr push to update all remotes at once,
mr commit -m 'message' to commit all the changes you have been doing in different castles...
Another very interesting option is to use its hooks to run scripts, for example, after checking out a castle to install the application using that castle, or simply to prepare scripts that setup other aspects of our system.
Having this bit of discipline with your dotfiles is highly rewarding. This way you can keep synchronized different systems where you work and, also, the next time you have to migrate to a new system you will only need the almost ubiquitous dependencies git, bash and perl to feel again at home.