我已经安装了电力线,默认配置显示了我当前的git分支。我还想显示该分支的状态(分阶段/非分段文件的数量等)我找到了电力线-基特状态,它似乎完成了这项工作,但我不知道如何配置它。
我已经按照https://github.com/jaspernbrouwer/powerline-gitstatus#configuration提供的说明将显示在~/.config/powerline/themes/shell/default.json上的配置条目复制到了~/.config/powerline/themes/shell/default.json。
下一节说明
然后,您可以通过将它添加到您的段配置中来激活Gitstatus段,例如在..config/powerline/themes/shell/default.json中: {“函数”:"powerline_gitstatus.gitstatus",“优先级”:40 }
该文件(.config/powerline/themes/shell/default.json)不存在,所以我创建了它,添加了该条目,然后重新启动了shell。但它并没有达到预期的效果。我想也许我应该把同样的条目添加到.config/powerline/config.json中,但我不知道该放在哪里。
如果有人能指导我度过这一切,我会非常感激的。
发布于 2019-11-17 11:47:13
对我来说,default主题根本没有显示任何VCS信息,所以我切换到了default_leftonly。利用这一主题,以下内容对我起了作用:
确保安装了git_status python模块:
python3 -m pip install powerline_gitstatus创建包含以下内容的文件~/.config/powerline/colorschemes/default.json
{
"groups": {
"gitstatus": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"gitstatus_branch": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"gitstatus_branch_clean": { "fg": "green", "bg": "gray2", "attrs": [] },
"gitstatus_branch_dirty": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"gitstatus_branch_detached": { "fg": "mediumpurple", "bg": "gray2", "attrs": [] },
"gitstatus_tag": { "fg": "darkcyan", "bg": "gray2", "attrs": [] },
"gitstatus_behind": { "fg": "gray10", "bg": "gray2", "attrs": [] },
"gitstatus_ahead": { "fg": "gray10", "bg": "gray2", "attrs": [] },
"gitstatus_staged": { "fg": "green", "bg": "gray2", "attrs": [] },
"gitstatus_unmerged": { "fg": "brightred", "bg": "gray2", "attrs": [] },
"gitstatus_changed": { "fg": "mediumorange", "bg": "gray2", "attrs": [] },
"gitstatus_untracked": { "fg": "brightestorange", "bg": "gray2", "attrs": [] },
"gitstatus_stashed": { "fg": "darkblue", "bg": "gray2", "attrs": [] },
"gitstatus:divider": { "fg": "gray8", "bg": "gray2", "attrs": [] }
}
}创建包含以下内容的文件~/.config/powerline/themes/shell/default_leftonly.json
{
"segments": {
"left": [
{
"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_gitstatus.gitstatus",
"priority": 40
},
{
"function": "powerline.segments.shell.cwd",
"priority": 10
},
{
"function": "powerline.segments.shell.jobnum",
"priority": 20
},
{
"function": "powerline.segments.shell.last_pipe_status",
"priority": 10
}
]
}
}并创建一个包含以下内容的文件~/.config/powerline/config.json
{
"ext": {
"shell": {
"theme": "default_leftonly"
}
}
}发布于 2020-04-30 14:19:55
为了找到正确的配置,我也付出了很大的努力。一旦得到正确的,我写了这个文章指导一个通过建立电力线。包括安装正确的字体和配置Visual代码。希望能帮上忙。
总结如下:
创建目录:
mkdir ~/.config/powerline
mkdir ~/.config/powerline/colorschemes
mkdir ~/.config/powerline/themes
mkdir ~/.config/powerline/themes/shell复制默认配置文件(可能path有另一个python版本):
cp ~/.local/lib/python3.7/site-packages/powerline/config_files/colorschemes/default.json ~/.config/powerline/colorschemes/
cp ~/.local/lib/python3.7/site-packages/powerline/config_files/colorschemes/solarized.json ~/.config/powerline/colorschemes/
cp ~/.local/lib/python3.7/site-packages/powerline/config_files/themes/shell/default.json ~/.config/powerline/themes/shell/将以下行添加到~/..config/powerline/着色方案中的两个文件中
这些行需要添加到“group”部分,并且在追加行之前不要忘记最后一行中的逗号。
"gitstatus": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"gitstatus_branch": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"gitstatus_branch_clean": { "fg": "green", "bg": "gray2", "attrs": [] },
"gitstatus_branch_dirty": { "fg": "gray8", "bg": "gray2", "attrs": [] },
"gitstatus_branch_detached": { "fg": "mediumpurple", "bg": "gray2", "attrs": [] },
"gitstatus_tag": { "fg": "darkcyan", "bg": "gray2", "attrs": [] },
"gitstatus_behind": { "fg": "gray10", "bg": "gray2", "attrs": [] },
"gitstatus_ahead": { "fg": "gray10", "bg": "gray2", "attrs": [] },
"gitstatus_staged": { "fg": "green", "bg": "gray2", "attrs": [] },
"gitstatus_unmerged": { "fg": "brightred", "bg": "gray2", "attrs": [] },
"gitstatus_changed": { "fg": "mediumorange", "bg": "gray2", "attrs": [] },
"gitstatus_untracked": { "fg": "brightestorange", "bg": "gray2", "attrs": [] },
"gitstatus_stashed": { "fg": "darkblue", "bg": "gray2", "attrs": [] },
"gitstatus:divider": { "fg": "gray8", "bg": "gray2", "attrs": [] }接下来,编辑文件~/..config/powerline/themes/shell/default.json
更改:
"function": "powerline.segments.shell.jobnum",
"priority": 20至:
"function": "powerline_gitstatus.gitstatus",
"priority": 40最后,重新启动电力线守护进程:
powerline-daemon --replace在此之后,GIT特定的信息应该在电力线内可见。
https://stackoverflow.com/questions/58482081
复制相似问题