如何在其他脚本中使用.bashrc中定义的别名? [英] How to use aliases defined in .bashrc in other scripts?

查看:134
本文介绍了如何在其他脚本中使用.bashrc中定义的别名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在〜/ .bashrc中,我定义了一些别名。但是我不能在其他shell脚本中使用它们,在这些脚本中我只能使用在那里定义的别名。即使我采购了bashrc,它仍然无法正常工作。我该怎么办?

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。我在bash中。

PS. I'm in bash.

推荐答案

您需要执行 shopt -s expand_aliases 〜/ .bashrc

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

这篇关于如何在其他脚本中使用.bashrc中定义的别名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆