是否可以为同一bash函数使用多个别名,而不必跨多个别名重新定义函数的内容?
您只需要为它定义别名,而不需要使用相同的主体来定义多个函数声明:
# 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'