pyhome10 Feb 2016
As someone who uses the terminal through most of the working day and for the majority of tasks, I like to use a customised shell environment and editor program. However, switching between machines - be they my office workstation, laptop, web servers I maintain or compute clusters I use for running simulations - inevitably ends up with the hassle of juggling a variety of configuration files between systems and updating them all with each change to my setup.
Sounds like a job for version control.
The Task at Hand
Dotfiles are simple text files in your home directory that store commands or
settings for the shell and other programs, so called because their names begin
., rendering them hidden by default in the shell and in other
programs. In my case, I have a set of configuration files for the bash and zsh
shells, the latter of which I use mainly, and a set of config files and
packages for vim, my primary text editor.
Storing these in a repository then poses a wee bit of a problem. As these files are often located directly in your home directory, they cannot so readily be stored in a typical version control repository. Fortunately, the excellent tool homesick by Josh Nichols provides an easy and convenient way to maintain your dotfiles in a reposiory and then automatically generate symbolic links to them from the appropriate location in your home directory.
Unfortunately, none of the systems I use come with Ruby, the language homesick is based on, preinstalled, and installing Ruby on compute clusters with archaic packages, even with the excellent RVM tool, quickly became as much of a hassle as the tool was meant to avoid.
As a self-diagnosed Python junkie, I waited until a spare minute and wrote my own homesick equivalent, pyhome. Following the same repository structure as homesick, pyhome replicates its basic functions:
pyhome clone- clone a new dotfile git repository to the right location
pyhome pull- update a dotfile git repository and its submodules
pyhome list- list existing repositories in the pyhome folder
pyhome link- generate symbolic links in the home folder for a repo
pyhome unlink- remove symbolic links for a repo
pyhome remove- remove a repo and its links
Conflicts between existing dotfiles and links in the home folder are reported, and the user is prompted to choose an action, preventing accidentally wiping existing configurations.
pyhome is written to ensure backwards compatability with reasonably modern versions of both Python 2 and 3, and without dependencies outside the standard library, making sure that it runs smoothly out of the box with the preinstalled system Python on any of the systems that I use.
pyhome is available on the Python Package Index (PyPI), and so
can be easily installed with
pip, the Python package manager:
You can also get the latest version of pyhome from its GitHub page. Comments, suggestions and contributions are welcome!