我可以在 .bashrc 之外的其他地方定义别名吗?

发布于 2024-08-28 03:26:01 字数 536 浏览 2 评论 0原文

我们有几个人在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

入怼 2024-09-04 03:26:01

难道您不想获取该文件(即在现有的 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) ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文