Shell Environment Upgrade and Cleanup: Part 1 - Requirements and Planning

| Comments

My ~/bin directory and Bash configuration had been slowly growing since some time around 1998 or so. Every few years I would cut back the weeds, but it had definitely been steadily growing right up until I switched to zsh a few years ago. That gave me an opportunity to cut pretty deeply and throw out a lot of cruft that I just don’t use anymore.

It has been a few years, and I think it is time to do a little weeding again. I would also like to try to make some improvements and additions.

Some of the goals

  • Clean up my zsh configuration
    • only define aliases for tools that are actually installed
    • move away from oh-my-zsh
  • Better, more automated revision control of config files
  • Single command to install my config on a new machine (like ssh-copy-id on steroids)
  • On new machines, automatically install
    • Required infrastructure (zsh, git)
    • Commonly used programs (ack, bwm-ng, autojump, tmux, etc)

Moving past oh-my-zsh

I really like the layout of oh-my-zsh’s directory structure. I used to maintain a single, large .bashrc file full of random aliases, functions, and environment variables. With oh-my-zsh, any file I drop in ~/.oh-my-zsh/custom/ will be included for me. I have a few hundred lines of code in there spread over two dozen files.

I’ve run into a problem with this several times, though. oh-my-zsh loads your custom config files first, then it loads its plugins. There have been times when I want to override just one little alias or settings that a plugin sets up for me, and the cleanest way to do that seems to be editing the plugin.

Tracking changes to files that ship with oh-my-zsh is made easy by git, but it doesn’t feel very natural to have to do this with oh-my-zsh… I’m equally happy maintaining my own fork of oh-my-zsh or just maintaining a set of configuration scripts within oh-my-zsh. I don’t think I should have to do both.

I’ve already begun switching to Sorin Ionescu’s Pretzo, which is a fork of oh-my-zsh. Sorin has eliminated oh-my-zsh’s line between plugins, libraries, and custom scripts. Everything in Pretzo is a “module.”

Better revision control of configuration files

Today I am maintaining four git repositories for files in my home directory. One each for ~/.oh-my-zsh, ~/bin, ~/.sawfish, and ~/.emacs.d. My ~/.xsession file lives in ~/.sawfish with a symlink back to my home directory. I used to keep my .bashrc in ~/bin but my .zshrc lives in my oh-my-zsh repository.

I came across a really great idea while investigating oh-my-zsh forks. It seems to have completely vanished from the Internet since I found it, though. He had a pair of scripts called persist and forget for moving configuration files into a git repository and leaving behind a symlink in their place.

He didn’t push the idea as far as I would have liked. His implementation could only store individual files. I would like to be able to persist entire directory trees with a single command. I also need a way to recreate the symlinks on other machines.

Pushing my shell config and ssh key to new machines

I’m a big fan and a heavy user of ssh-copy-id. It is a good, lazy way to push your public key out to a new server. I’d like be able to run a single command to push my ssh public key and my entire shell config out to fresh servers with a single command.

Comments