bash PS1 提示的三角形背景
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32443522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Triangular background for bash PS1 prompt
提问by BaRud
I am trying to get a triangular background for bash PS1 prompt.
I have tried the existing library called powerline
but it seems to be heavy for my ageing laptop. I have managed to get the background colour, but have no idea of getting the shape. Currently what I have is:
.
我已经尝试了现有的库,powerline
但它对于我老化的笔记本电脑来说似乎很重。我已经设法获得背景颜色,但不知道获得形状。目前我拥有的是:
.
Is there any straight-forward way of having those shape?
有没有直接的方法来获得这些形状?
I am using:
我在用:
$ echo $TERM
xterm-256color
$ echo $SHELL
/bin/bash
$ bash --version
GNU bash, version 4.3.42(1)-release (x86_64-redhat-linux-gnu)
采纳答案by brujoand
You need to have powerline patched fonts installed. Get them here
您需要安装电力线修补字体。把它们弄到这里
And you need to configure your terminal to use them. (this ofc depends on your terminal but probably something like settings -> appearance -> fonts)
你需要配置你的终端才能使用它们。(此 ofc 取决于您的终端,但可能类似于设置 -> 外观 -> 字体)
I've done something similar if you want a startingpoint: prompt.bashYou can try it out by running . prompt.bash
.
如果你想要一个起点,我已经做了类似的事情:prompt.bash你可以通过运行. prompt.bash
.
Basically all you need if the fonts are installed and enabled is this $'\uE0B0'
somewhere in your PS1. It's the utf8 code for the fancy triangle. Assuming you're on a recent version of bash with some utf8 as locale, that should do it. Try echo -e $'\uE0B0'
in your terminal to test it.
基本上,如果安装并启用了字体,您所需要的就是$'\uE0B0'
PS1 中的某个地方。这是花式三角形的utf8代码。假设您使用的是最新版本的 bash,其中一些 utf8 作为语言环境,应该这样做。尝试echo -e $'\uE0B0'
在您的终端中进行测试。