Dou*_*ker 10 zsh intellij-idea tmux
所以我遇到了一些我无法解释的非常奇怪的行为.我最近跳上了tmux的潮流并设置了我的shell配置,以便在打开终端窗口时自动启动tmux.大约在同一时间,我开始得到一个错误,打开一个新的终端会话将正确启动tmux但然后显示:
zsh-newuser-install: startup files exist, aborting.
Use the argument -f if you want to force the function to be run again.
douglasparker@gryphon /home/douglasparker%
Run Code Online (Sandbox Code Playgroud)
现在我有一个非常深入的配置,我自己PS1显然没有使用.但是我可以通过简单运行来解决这个问题
douglasparker@gryphon /home/douglasparker% source ~/.zshrc
douglasparker@gryphon (~)
[17-10-11 11:35:59]$
Run Code Online (Sandbox Code Playgroud)
因此,简单地采购zsh的运行配置可以修复它并加载应有的一切,这没有任何意义,因为它应该自动获取,但事实并非如此.
我还发现只有当第一个tmux会话从Intellij中嵌入的终端启动时才会发生这种情况.如果我正常打开终端(甚至在Android Studio中),它可以正常工作并~/.zshrc自动获取资源.但是从Intellij开放特别产生了这个bug.有趣的是,如果Intellij首先打开,那么打开tmux的任何后续终端都会显示相同的问题.但是,如果我先打开另一个终端并保持打开状态,那么在Intellij中启动终端可以正常工作.
通过"第一"我的意思是没有现有的tmux服务器.如果我关闭退出所有打开的tmux窗口(这会tmux ls产生"无法连接到服务器"),那么如果我打开的下一个会话来自通用终端,那么我很好并将继续直到所有 tmux窗口再次关闭.但是,如果第一个 tmux窗口来自Intellij,则此错误将浮出水面,并将继续所有终端,直到我再次退出所有tmux窗口.
重现这个我发现的最低配置是以下~/.zshrc文件:
#!/bin/bash
# If this is a raw terminal, just open tmux and then exit
# The inner session will re-source this script and load the configuration
if ! { [ "${TERM}" = "screen" ] && [ -n "${TMUX}" ]; } then
# Open tmux immediately
echo "Sourced ~/.zshrc: Not in tmux" >> tmux.log
tmux
exit
else
# Must already be within tmux
echo "Sourced ~/.zshrc: In tmux" >> tmux.log
echo hello
fi
Run Code Online (Sandbox Code Playgroud)
所有这一切都是检查它是否在tmux内.如果没有,则打开tmux,并在tmux停止后退出.在其中打开会话应该第二次获取此脚本,并hello在tmux中打印到控制台.
如果没有TMUX会议开着,我推出一个正常的终端窗口(如果有是从一个正常的终端窗口现有TMUX会话和我在推出的IntelliJ终端),然后我得到预期的输出:
hello
douglasparker@gryphon ~% cat tmux.log
Sourced ~/.zshrc: Not in tmux
Sourced ~/.zshrc: In tmux
douglasparker@gryphon ~%
Run Code Online (Sandbox Code Playgroud)
如果没有打开tmux会话,我在Intellij中启动终端窗口,那么我得到输出:
zsh-newuser-install: startup files exist, aborting.
Use the argument -f if you want to force the function to be run again.
douglasparker@gryphon /home/douglasparker% cat tmux.log
Sourced ~/.zshrc: Not in tmux
douglasparker@gryphon /home/douglasparker%
Run Code Online (Sandbox Code Playgroud)
这都是在Intellij的tmux会话中打印的.因此,它是正确的采购~/.zshrc文件一次并启动TMUX,但它根本没有采购~/.zshrcTMUX内的第二次,这些非常特殊的情况下,我不知道为什么.
我也试图改变我的壳暂时bash和发现问题并没有在bash的重现.所以这个问题似乎来自zsh,tmux和Intellij之间的集成.
我意识到这是一个非常具体的问题,但有谁知道可能导致这类问题的原因是什么?查找zsh错误并没有真正帮助我找到原因.Intellij是否有一些特殊的终端窗口可能导致这种行为?是否有任何记录的原因,为什么zsh拒绝采购~/.zshrc?
Dou*_*ker 18
基于https://youtrack.jetbrains.com/issue/IDEA-165272,在Intellij中,取消选中设置>工具>终端> Shell集成为我解决了这个问题.
我不知道该设置实际上做了什么,也找不到任何文档,但是禁用它可以解决问题.
谢谢CrazyCoder,你是一个节省生命的人!
| 归档时间: |
|
| 查看次数: |
1423 次 |
| 最近记录: |