16

I am trying to get a triangular background for bash PS1 prompt. as shown here

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: my PS1.

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)
BaRud
  • 3,055
  • 7
  • 41
  • 89
  • 1
    Are you using one of the [patched fonts](https://github.com/powerline/fonts) for powerline? – chepner Sep 07 '15 at 17:54
  • I am not using powerline – BaRud Sep 07 '15 at 17:55
  • 2
    The triangles are, AFAIK, just special characters included in those fonts. – chepner Sep 07 '15 at 17:57
  • @chepner: At last I have found the font that are used. Also I tried to dig the powerline sourcecode in github, but failed to get how should I use that font...i.e. how to change the font in PS1. Kindly help – BaRud Sep 07 '15 at 19:47

1 Answers1

9

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)

I've done something similar if you want a startingpoint: sbp You can try it out by running . 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.

brujoand
  • 815
  • 8
  • 15
  • I have installed those fonts, and confirm `echo -e $'uE0B0'` works as intended. But not in my PS1 `PS1="[\u@\h$'\uE0B0' \W]\$ " ` – BaRud Sep 07 '15 at 20:18
  • ah, my bad. You need to evaluate it first. For instance by assigning it first: triangle=$'\uE0B0' and then use $triangle in your PS1. There might be a more elegant way, but this is what I did. – brujoand Sep 07 '15 at 20:26
  • Hi....one last thing....where I will get those utf8 encoding? like, say, a filled ")"? I tried to search utf8-encoding e.g. http://www.utf8-chartable.de/unicode-utf8-table.pl?start=57472&number=128, and they are showing different character – BaRud Sep 07 '15 at 20:56
  • I'm not sure I understand your question but if you're looking for the powerline path separator it's $'\uE0B1'. If you're looking for the ) equivalent of the triangle I'm not sure tbh. – brujoand Sep 07 '15 at 21:03
  • 2
    Maybe we could update the answer pointing to https://github.com/brujoand/sbp ? – Dilettant Dec 26 '19 at 05:44
  • I did `sudo apt install fonts-powerline`. Then nothing changed until I opened a new terminal. – ctrl-alt-delor Oct 16 '21 at 16:40
  • super old thread, but as I still find it through google... in regards to the fonts... from the sbp webpage: > Now the hard_to_remember part. Change the settings of your terminal emulator. you can not just install them, you also have to enable them – superhero Aug 30 '23 at 13:41