Multiple names / aliases for a function in bash

Gru

Is it possible to have multiple aliases for the same bash function without have to redefine the content of the function across multiple aliases ?

Gru

You'll just have to define the alias for it rather than having multiple function declarations with the same body:


# attach a bash shell to a running docker container
function dexb {
    docker exec -it "$1" /bin/bash
}

# attach a sh shell to a running docker container
function dexs {
    docker exec -it "$1" /sh
}

# Now instead of creating another function say 'dex' with the same 
# content as the function 'dexb'

# I'll just create an alias

alias 'dex'='dexb' 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related