How to use aliases defined in .bashrc in other scripts?

Dutor picture Dutor · Mar 9, 2011 · Viewed 14.6k times · Source

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.

Answer

Dennis Williamson picture Dennis Williamson · Mar 9, 2011

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