我可以在 .bashrc 之外的其他地方定义别名吗?
我们有几个人在 Linux Box 上使用相同的登录 ID。
我想定义自己的别名而不干扰任何人。
在 .bashrc
中,我为 bash 文件定义了一个别名,定义了我自己的别名。
alias luc=/full/path/to/my/def_alias_luc.sh
文件 /full/path/to/my/def_alias_luc.sh 包含
#!/bin/bash
echo ""
echo "Defining Luc's aliases"
echo ""
echo ""
echo "aliases before..."
echo ""
alias
alias vimluc="vim -u /full/path/to/my/.vimrc "
echo ""
echo "aliases after"
echo ""
alias
执行 /full/path/to/my/def_alias_luc.sh 后,别名仍然未定义。
我想念什么?
We are several persons using the same login id on Linux Box.
I want to define my own aliases without interfering with anyone.
In the .bashrc
, I define a alias to my bash file defining my own aliases.
alias luc=/full/path/to/my/def_alias_luc.sh
The file /full/path/to/my/def_alias_luc.sh contains
#!/bin/bash
echo ""
echo "Defining Luc's aliases"
echo ""
echo ""
echo "aliases before..."
echo ""
alias
alias vimluc="vim -u /full/path/to/my/.vimrc "
echo ""
echo "aliases after"
echo ""
alias
After executing /full/path/to/my/def_alias_luc.sh, the alias is still undefined.
What do I miss ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
难道您不想获取该文件(即在现有的 bash 进程中运行它)而不是生成一个新 bash 进程(因为脚本的第一行将建议你正在做)?
Don't you want to source that file (i.e. run it within the existing bash process) rather than spawn off a new bash process (as the first line of the script would suggest you're doing) ?