我alias se='sudo -E '
输入/etc/profile
并重新启动。然后我输入se
,终端只是说“找不到命令”。
为什么别名在 /etc/profile 中不可用?如何解决?
编辑:
我曾尝试放alias se='sudo -E '
的/etc/profile
,~/.zprofile
,~/.zshrc
/etc/profile
失败的/etc/zprofile
失败的/etc/zshenv
成功的/etc/zshrc
成功的~/.zprofile
失败的~/.zshrc
成功的参考:
在您使用时/etc/profile
,我假设您希望仅针对 shell ( zsh
) 的登录会话执行此操作。
那是因为zsh
默认情况下/etc/profile
在启动登录 shell 时不读取。要仅为登录 shell设置任何全局参数,请使用文件/etc/zsh/zprofile
.
要设置适用于任何类型调用的内容,请/etc/zsh/zshenv
改用。典型/通用顺序是zshenv > zprofile > zshrc > zlogin
(取决于调用和可用性)。
不用说,对于任何用户特定的参数,您应该使用用户特定的.zprofile
ie~/.zprofile
来代替。
笔记:
如果您希望为任何交互式 shell 会话执行此操作,请使用.zshrc
(/etc/zshrc
或~/.zshrc
)
如果您正在考虑使用相关文件中的通用/etc/profile
(或类似),source
( .
)/etc/profile
用于zsh
.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句