Bash – How to use aliases defined in .bashrc in other scripts

aliasbash

In ~/.bashrc, I defined some aliases. But I cannot use them in other shell scripts, where I can only use aliases defined right there. Even though I sourced bashrc, it still did not work. What should I do?

PS. I'm in bash.

Best Answer

You need to do shopt -s expand_aliases in the script in addition to sourcing ~/.bashrc.