我喜欢zsh
,但我不确定在哪里放置我的$PATH
和其他变量断言?我发现它们分散在文件之间.zshrc
.zprofile
.bashrc
.bash_profile
,有时会翻倍.
我认识到,具有内部的任何bash
文件,没有多大意义看到,因为我使用的zsh
,但正是我应该把我rvm
,python
,node
等添加到我的$PATH
?
有没有我应该使用(即一个特定的文件.zshenv
,其不会没有目前在我的安装存在),我目前使用的手机之一,或者它甚至重要吗?
sim*_*ont 129
tl;博士版:使用 ~/.zshrc
并阅读手册页以了解之间的区别:
~/.zshrc
,~/.zshenv
和~/.zprofile
.
在我对kev给出的答案的评论中,我说:
这似乎是不正确的 - /etc/profile未在我能找到的任何zsh文档中列出.
事实证明这部分是不正确的:/etc/profile
可能来自zsh
.但是,只有在zsh
"被调用为sh
或ksh
" 时才会出现这种情况; 在这些兼容模式中:
通常的zsh启动/关闭脚本不会执行.登录shell源/ etc/profile后跟$ HOME/.profile.如果在调用时设置ENV环境变量,则在概要文件脚本之后获取$ ENV.ENV的值在被解释为路径名之前经过参数扩展,命令替换和算术扩展.[ 男子zshall,"兼容性" ].
登录时,Zsh按以下顺序提供以下文件:
/etc/profile
此文件由登录时所有与Bourne兼容的shell提供
这implys /etc/profile
是总是读通过zsh
在登录时-我没有与Arch Linux的项目的经验; 维基可能对于该分发是正确的,但通常不正确.该信息是比较zsh的手册页不正确的,似乎并不适用于zsh的在OS X(在路径$PATH
集/etc/profile
不使其向我的zsh会话).
我应该在哪里将我的rvm,python,节点等添加到我的$ PATH?
一般来说,我会导出我$PATH
的~/.zshrc
,但它是值得拥有的读zshall手册页,特别是"启动/关闭文件"部分- ~/.zshrc
阅读的互动炮弹,这可能会或可能不适合您的需求-如果你想$PATH
为zsh
你调用的每个shell(无论是否interactive
,不是,login
不是等),~/.zshenv
都是更好的选择.
是否有我应该使用的特定文件(即我的安装中当前不存在的.zshenv),我目前正在使用的文件之一,或者甚至是否重要?
在启动时读取了一堆文件(检查链接man
页面),这是有原因的 - 每个文件都有它的特定位置(每个用户的设置,特定于用户的设置,登录shell的设置,每个shell的设置,等等).
不要担心~/.zshenv
不存在 - 如果你需要它,制作它,它将被阅读.
.bashrc
和.bash_profile
是不是阅读zsh
,除非你明确地从源头他们~/.zshrc
或相似; 之间的语法bash
和zsh
是不是总是兼容.两者都是为设置.bashrc
而.bash_profile
设计的bash
,而不是zsh
设置.
jor*_*jor 28
以下是STARTUP/SHUTDOWN FILES部分下zsh手册页中的文档.
Commands are first read from /etc/zshenv this cannot be overridden.
Subsequent behaviour is modified by the RCS and GLOBAL_RCS options; the
former affects all startup files, while the second only affects global
startup files (those shown here with an path starting with a /). If
one of the options is unset at any point, any subsequent startup
file(s) of the corresponding type will not be read. It is also possi-
ble for a file in $ZDOTDIR to re-enable GLOBAL_RCS. Both RCS and
GLOBAL_RCS are set by default.
Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login
shell, commands are read from /etc/zprofile and then $ZDOTDIR/.zpro-
file. Then, if the shell is interactive, commands are read from
/etc/zshrc and then $ZDOTDIR/.zshrc. Finally, if the shell is a login
shell, /etc/zlogin and $ZDOTDIR/.zlogin are read.
Run Code Online (Sandbox Code Playgroud)
从这里我们可以看到订单文件被读取是:
/etc/zshenv # Read for every shell
~/.zshenv # Read for every shell except ones started with -f
/etc/zprofile # Global config for login shells, read before zshrc
~/.zprofile # User config for login shells
/etc/zshrc # Global config for interactive shells
~/.zshrc # User config for interactive shells
/etc/zlogin # Global config for login shells, read after zshrc
~/.zlogin # User config for login shells
~/.zlogout # User config for login shells, read upon logout
/etc/zlogout # Global config for login shells, read after user logout file
Run Code Online (Sandbox Code Playgroud)
您可以在此处获取更多信息.
abe*_*312 14
我有类似的问题(在bash终端命令工作正常,但zsh显示命令未找到错误)
只需将之前粘贴在〜/ .bashrc中的内容粘贴到:
~/.zshrc
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
88697 次 |
最近记录: |