Search code examples
bashfunctionscriptingsynonym

How do I add function synonyms in bash scripts?


My ~/.bashrc file contains several custom-made functions and I would like some of them to have synonyms. For example, I have the following identical functions in this script that I'd to combine by use of synonyms if possible:

function pyimmassl {
    pushd /pywiki
    python imagetransfer.py -file:$1.txt -keepname -tofamily:Linux_Wiki -tolang:en
    popd
}

function pyimagemassl {
    pushd /pywiki
    python imagetransfer.py -file:$1.txt -keepname -tofamily:Linux_Wiki -tolang:en
    popd
}

Solution

  • Just create an alias:

    function pyimmassl {
        pushd /pywiki
        python imagetransfer.py -file:$1.txt -keepname -tofamily:Linux_Wiki -tolang:en
        popd
    }
    
    alias pyimagemassl=pyimmassl
    

    Now you can call the function using either name.