Recently, I’ve done a lot of work on my dotfiles. One thing that always bothers me is the sheer amount of aliases I have laying around everywhere. Kinda frustrating. Additionally, I have a set of scripts I in my env which I’d really like to automatically set aliases to easily.

A commonly accepted idea is to separate all your aliases out into something like an .aliasrc file. This is definitely very helpful. However, I would love something that could manage my aliases for me, telling me when thers a duplicate, or automatically making an alias for every available .sh file in a given directory..

Example:

aa addkey "ssh-add -a ~/.ssh/id_rsa"

At present, this will have to do:

# source aliases
ALIASFILE=~/.aliasesrc
source $ALIASFILE
function add_alias() {
    if [[ -z $1 || -z $2 || $# -gt 2 ]]; then
        echo usage:
        echo "\t\$$0 ll 'ls -l'"
    else
        echo "alias $1='$2'" >> $ALIASFILE
        echo "alias ADDED to $ALIASFILE"
    fi
}
Mario Loria is a builder of diverse infrastructure with modern workloads on both bare-metal and cloud platforms. He's traversed roles in system administration, network engineering, and DevOps. You can learn more about him here.