Digital housekeeping: ~/.alias

Today, alongside clearing out about an inch-high stack of physical paperwork, I hacked back the hypertrophy in my ~/.alias file. This is the file that sets up the abbreviations and utilities that are available on the commandline for me, beyond the system defaults.

This file is part of a small set of material which gets hodded from laptop to laptop and from one shell account to another; those dotfiles go back to 1995 in my lamentable case, and represent a series of nine personal machines such as laptops, and a bunch of work/social UNIX and Linux accounts. Continuity is good; clutter is bad.

Getting the most out of muscle memory means having roughly the same shortcuts and commands everywhere, so some means must be found for keeping my personal day-to-day machine in sync with the three or four others I must use for work or social matters. Nowadays there is no longer NFS to centralise all this.

Ultimately this material is pretty valuable. It saves huge amounts of repeated effort, and is how Ken Thompson and Doug McIlroy wanted us to use UNIX: gradually building up tools based on other tools. I have a tool just for finding out what commands I am overusing, so I can save them as aliases or scripts. That is of course upstream of the problem of having so many saved scripts that the system starts to become cluttered and unmanageable.

tabulate-history () 
{ 
    history | awk '{$1 = ""; print}' | sort | uniq -c | sort -n
}

Previous efforts

~/bin

The last time I looked into this issue, I found I had a sizable .alias file, but also about 150 scripts and tools in ~/bin, and a handful elsewhere. The campaign was on:

This went a long way to making stuff manageable, maintanable, surveyable, findable etc again.

In case it's useful, the install.sh files for each little package looked something like this:

#!/bin/bash

set -eu

PKG=$(basename $(realpath $(dirname $0)))
STOW=/usr/local/stow
DIR=$STOW/$PKG

install -d $DIR/bin
install -m 755 -t $DIR/bin bin/*

cd $STOW
stow $PKG

~/.emacs.d/init.el

And the time-before-last was a non-trivial campaign to hack back my Emacs initialisation file. That resulted in the various functions and setting I'd established getting broken into a dozen little libraries / packages / whatever Emacs calls them. I still haven't solved the problem of distributing this stuff to multiple machines.

Taming ~/.alias

A three part campaign:

What sorting the .alias file showed me was:

What I mean by "shortcuts" vs "fixes" above is as follows:

Fixes

The developers didn't choose sensible defaults, or they Poetteringed the defaults to something incompatible:

alias w3m='w3m -no-mouse'
alias tda='tda -p medium'
alias ls='ls --color=auto -N'
alias watch='watch -n 1'
alias R='R --no-save --no-restore'
alias a2ps='a2ps --pretty-print=plain'

Shortcuts

The developers did nothing wrong, but I frequently want to call the program with the same arguments:

alias docx2pdf='libreoffice --headless --convert-to pdf'
alias xsco='xclip -selection clipboard -o'
wt ()   { while true; do "$@"; sleep 1; done }
gpom () { git push origin master; }

Anyway, I hope this proves useful to someone!

Gemlog index
Site index