我zsh
用作我的默认 shell 并.zshrc
用于修改我的环境变量。当我gvim
从终端开始时,一切都很好,但是如果我用桌面图标启动 gvim,我的 env 变量就消失了。(只是为了清除它,:shell
很好,但:!
命令不是)
我试图将我的环境变量移动到,.zprofile
但没有奏效。如果我将它们移动到.profile
它的工作原理,但是我又需要复制我的变量,因为zsh
它没有读取.profile
我对 .shell 的内部处理知之甚少gvim
。是否有可能读取.zshrc
或.zprofile
用于:!
命令?
注意:我正在使用ubuntu
系统。也欢迎任何涉及操作系统的优雅解决方案。
使用
.zshrc
修改我的环境变量
这就是你问题的根本原因。.zshrc
是交互式 shell 会话的启动文件。使用它来设置 shell 设置,而不是设置环境变量。环境变量通常在会话文件中设置,例如.profile
. 请参阅.bashrc 的替代方案(适用于 .bashrc的.bashrc
也适用于.zshrc
)。
如果 zsh 是您的登录 shell,它不会读取~/.profile
,但会读取~/.zprofile
. 请注意,即使 zsh 是您的交互式 shell,它也不一定是您的登录 shell:您可以将其/bin/sh
用作登录 shell 并SHELL=$(command -v zsh)
在您的环境中进行设置,以便终端模拟器等运行 zsh。既然你说定义你的环境变量~/.zprofile
不起作用,这可能是你的系统已经设置的方式,但是如果没有更准确的信息,很难说“不起作用”。
如果您的登录 shell 是 zsh,请将以下行放入您~/.zprofile
的阅读中.profile
:
emulate ksh -c '. ~/.profile'
Run Code Online (Sandbox Code Playgroud)
您通常可以使用普通. ~/.profile
的.profile
.
如果它不是交互式或登录 shell,我认为您只能使用~/.zshenv
. 以下内容来自“启动/关闭文件”部分zshall(1)
:
Commands are then read from $ZDOTDIR/.zshenv. If the shell is a login
shell, commands are read from /etc/zsh/zprofile and then $ZDOT-
DIR/.zprofile. Then, if the shell is interactive, commands are read
from /etc/zsh/zshrc and then $ZDOTDIR/.zshrc. Finally, if the shell
is a login shell, /etc/zsh/zlogin and $ZDOTDIR/.zlogin are read.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
521 次 |
最近记录: |