DEV Community

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

Collapse
 
syntaxseed profile image
SyntaxSeed (Sherri W)

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."
}