我已经安装了 powerline,默认配置显示了我当前的 git 分支。我还想显示该分支的状态(暂存/未暂存文件的数量等...)我发现powerline-gitstatus似乎可以完成这项工作,但我不知道如何配置它..
我已将https://github.com/jaspernbrouwer/powerline-gitstatus#configuration中显示的配置条目复制到~/.config/powerline/themes/shell/default.json那里提供的说明中。
下一节指出
然后你可以通过将 Gitstatus 段添加到你的段配置中来激活它,例如在 .config/powerline/themes/shell/default.json 中:
Run Code Online (Sandbox Code Playgroud){ "function": "powerline_gitstatus.gitstatus", "priority": 40 }
该文件 ( .config/powerline/themes/shell/default.json) 不存在,所以我创建了它,添加了该条目,然后重新启动了我的 shell。然而并没有达到预期的效果。我想也许我应该添加相同的条目,.config/powerline/config.json但我不知道把它放在哪里。
如果有人能指导我完成这个,我将不胜感激。
对我来说,default主题根本没有显示任何 VCS 信息,所以我切换到default_leftonly. 使用该主题,以下内容对我有用:
创建一个~/.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": [] }
}
}
Run Code Online (Sandbox Code Playgroud)
创建一个~/.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
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
并创建一个~/.config/powerline/config.json包含
{
"ext": {
"shell": {
"theme": "default_leftonly"
}
}
}
Run Code Online (Sandbox Code Playgroud)
小智 5
我也花了很多功夫才找到正确的配置。一旦正确,我就写了这篇文章来指导人们完成电力线的设置。包括安装正确的字体和配置 Visual Studio Code。我希望它有帮助。
总结一下,请执行以下操作:
创建目录:
mkdir ~/.config/powerline
mkdir ~/.config/powerline/colorschemes
mkdir ~/.config/powerline/themes
mkdir ~/.config/powerline/themes/shell
Run Code Online (Sandbox Code Playgroud)
复制默认配置文件(也许路径有另一个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/
Run Code Online (Sandbox Code Playgroud)
将以下行添加到 ~/.config/powerline/colorschemes 中的两个文件中
这些行需要添加到“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": [] }
Run Code Online (Sandbox Code Playgroud)
接下来,编辑文件 ~/.config/powerline/themes/shell/default.json
改变:
"function": "powerline.segments.shell.jobnum",
"priority": 20
Run Code Online (Sandbox Code Playgroud)
到:
"function": "powerline_gitstatus.gitstatus",
"priority": 40
Run Code Online (Sandbox Code Playgroud)
最后,重新启动电力线守护进程:
powerline-daemon --replace
Run Code Online (Sandbox Code Playgroud)
之后,GIT 特定信息应该在电力线中可见。
| 归档时间: |
|
| 查看次数: |
5478 次 |
| 最近记录: |