你好,
我最近在新的笔记本电脑ArchLinux中安装了powerline,并出于某种原因使用了默认的shell主题,git分支不再出现在终端的右侧。 我的屏幕上有很多空间可以显示,但是没有显示。 我什至尝试了"priority": None
,它应该总是使其显示出来,但这也不起作用。
电力线版本:2.5.1
操作系统:Archlinux
安装者:Pacman,发行版的程序包管理器
我将默认外壳主题重命名为lef.json
并进行了一些更改以确保它被拾取并且所做的更改也被拾取,因此我们可以确定电力线可以识别,解析和使用这些文件。
config.json
{
"common": {
"term_truecolor": false
},
"ext": {
"ipython": {
"colorscheme": "default",
"theme": "in",
"local_themes": {
"rewrite": "rewrite",
"out": "out",
"in2": "in2"
}
},
"pdb": {
"colorscheme": "default",
"theme": "default"
},
"shell": {
"colorscheme": "default",
"theme": "lef",
"local_themes": {
"continuation": "continuation",
"select": "select"
}
},
"tmux": {
"colorscheme": "default",
"theme": "default"
},
"vim": {
"colorscheme": "default",
"theme": "default",
"local_themes": {
"__tabline__": "tabline",
"cmdwin": "cmdwin",
"help": "help",
"quickfix": "quickfix",
"powerline.matchers.vim.plugin.nerdtree.nerdtree": "plugin_nerdtree",
"powerline.matchers.vim.plugin.commandt.commandt": "plugin_commandt",
"powerline.matchers.vim.plugin.gundo.gundo": "plugin_gundo",
"powerline.matchers.vim.plugin.gundo.gundo_preview": "plugin_gundo-preview"
}
},
"wm": {
"colorscheme": "default",
"theme": "default"
}
}
}
lef.json主题(基本上为外壳复制default.json的粘贴)
{
"segments": {
"left": [
{
"function": "powerline.segments.shell.mode"
},
{
"function": "powerline.segments.common.net.hostname",
"priority": 10
},
{
"function": "powerline.segments.common.env.user",
"priority": 30
},
{
"function": "powerline.segments.common.env.virtualenv",
"priority": 50
},
{
"function": "powerline.segments.shell.cwd",
"priority": 10
},
{
"function": "powerline.segments.shell.jobnum",
"priority": 20
}
],
"right": [
{
"function": "powerline.segments.shell.last_pipe_status",
"priority": 10
},
{
"function": "powerline.segments.common.vcs.stash",
"priority": 50
},
{
"function": "powerline.segments.common.vcs.branch",
"priority": 40
}
]
}
}
任何有关如何解决此问题的想法将不胜感激。
git status
输出什么? 您可以尝试在交互式python会话中手动运行powerline.lib.vcs.guess
吗?
@ s-ol git status
和git branch
正常工作。 我在git存储库中。
但是powerline.lib.vcs.guess
在交互式python会话中不起作用。 或者至少我认为它不起作用,因为它返回一个空对象。 我对电力线内部知识了解不多,所以让我在这里为您粘贴一下:
Python2:
Python 2.7.12 (default, Jun 28 2016, 08:31:05)
[GCC 6.1.1 20160602] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import powerline.lib.vcs as vcs
>>> vcs.guess(".", False)
<powerline.lib.vcs.git.Repository object at 0x7f495258aeb0>
>>> a = vcs.guess(".", False)
>>> a.__dict__
{}
Python3:
Python 3.5.2 (default, Jun 28 2016, 08:46:01)
[GCC 6.1.1 20160602] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import powerline.lib.vcs as vcs
>>> vcs.guess(".", False)
<powerline.lib.vcs.git.Repository object at 0x7f93f665ce58>
>>> a = vcs.guess(".", False)
>>> a.__dict__
{}
@LefterisJP为什么您认为它是空的? __dict__
并不是唯一包含对象属性的地方。 实际上,那里肯定没有属性,所讨论的类正在使用__slots__
。
此函数无法返回“空”对象,它返回可用存储库或“无”。
想知道是否在更改配置后是否重新加载了守护程序(如果使用zsh + zpython,请重新启动zsh或使用powerline-reload-config
)。
@ ZyX-我知道了。 不知道python的__slots__
。 感谢那!
所以:
>>> a.__slots__
('directory', 'create_watcher')
我没有守护程序在运行。 我只有:
source /usr/lib/python2.7/site-packages/powerline/bindings/zsh/powerline.zsh
在我的.zshrc
。
这样,它在我的另一台计算机上运行了很长时间。 我不认为我曾经使用过守护程序。
@LefterisJP您解决了吗? 有趣的是,如果为shell配置选择主题default_leftonly.json,则git分支将出现在左侧的提示上。 看起来有些东西阻止了正确的段出现在外壳上。
@LefterisJP ahhh ...刚刚找到了一些其他文档,其中说bash不支持右侧提示。 因此,这说明了为什么默认的外壳主题不起作用。 我要继续使用default_leftonly主题。
您是否正在使用bash或其他shell。 如果是前者,那可能就是它对您也不起作用的原因。
我正在使用zsh而不是bash。 没有时间进一步看这个问题,但它仍然存在。 正如您还注意到的那样,使用default_leftonly.json
会在左侧显示分支,但在默认情况下不会显示。
在Mac OS Sierra上出现相同的问题,+ 1
刚在我的Arch上安装了电力线,即可确认默认主题未显示git分支。 切换到default_leftonly
主题可以解决此问题。
与zsh相同的问题。
通过杀死所有挂起的powerline-daemon
进程来解决。
更改为default_leftonly
对我来说也是必要的,并且由于我不需要定制,也没有兴趣,而且文档主要针对此,所以我最终只创建了一个配置文件来更改主题:在应用配置后https://github.com/powerline/powerline/issues/186#issuecomment -247810572和powerline-daemon -q --replace
(请注意这里的-q
在后台生成它!)。
我将vim的主题更改为default_leftonly
,仍然一无所有...
我也很努力地找出正确的配置。 一旦正确,我写了这篇文章来指导建立电力线。 希望对您有所帮助。
最有用的评论
@LefterisJP ahhh ...刚刚找到了一些其他文档,其中说bash不支持右侧提示。 因此,这说明了为什么默认的外壳主题不起作用。 我要继续使用default_leftonly主题。
您是否正在使用bash或其他shell。 如果是前者,那可能就是它对您也不起作用的原因。