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)
4
  • 1
    Are you using one of the patched fonts for powerline?
    – chepner
    Sep 7, 2015 at 17:54
  • I am not using powerline
    – BaRud
    Sep 7, 2015 at 17:55
  • 2
    The triangles are, AFAIK, just special characters included in those fonts.
    – chepner
    Sep 7, 2015 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 7, 2015 at 19:47

1 Answer 1

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.

7
  • 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 7, 2015 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 7, 2015 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. utf8-chartable.de/…, and they are showing different character
    – BaRud
    Sep 7, 2015 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 7, 2015 at 21:03
  • 2
    Maybe we could update the answer pointing to github.com/brujoand/sbp ?
    – Dilettant
    Dec 26, 2019 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.