loading...

New Year, New Terminal: Alias Your Directories the Unix Way

Ben Myers on January 02, 2020

This article covers how to alias your directories on Unix, and was originally published on my blog. Additionally, you may be interested in the Wind... [Read Full]
markdown guide
 
 

For anyone who wants a matching function to remove the aliases...

function del_alias() {
    if [[ "$#" -ne 1 ]]
    then
        echo "USAGE: del_alias <alias name>"
        return 0
    elif [[ -n "$(alias $1 2>/dev/null)" ]]
    then
        sed -i "/alias $1=/d" ~/.bashrc
        source ~/.bashrc
        echo "Alias removed."
        return 0
    fi
    echo "Alias does not exist."
}
 

In most of the places I've worked the systems are very locked down and many are running Solaris Unix or AIX, so downloading libraries or compiling stuff from the web is not an option unless you want to be walked out, so using aliases like this is far more useful than z or goto (excellent tools! But only an option @ home).

How locked down, you ask? My office defaults you to ksh and the only way to change that is to have exec bash in my .profile

 
 

I hadn't heard about this before. This is really cool! Thank you for sharing!

 

Yeah it's an amazing tool! I can't live without it 😄 You won't ever need directory aliases again!

code of conduct - report abuse