Ubuntu – How to get a a graphical BASH prompt

19.04bashcommand line

I want something that looks like this:

Is there any way to achieve this?
If so, how can I do this?

NOTE: I use Kubuntu Disco in case that is important.

Best Answer

For Kubuntu 19.04, install fonts-powerline using sudo apt install fonts-powerline. Your system should also have fonts-hack.

Visit this site and copy the entire script, all 348 lines as on 20190906, to ~/bin and save it as powerline.sh or whatever. Use the file manager to make the script executable.

(Note that ~/bin is by default in your system's path and so you do not need something like $HOME/bin/.powerline.sh.)

Open konsole and, from your home folder, run

echo "source powerline.sh" >> ~/.bashrc

Doing so will add

source powerline.sh

as the last line of your ~/.bashrc.

From your still open konsole window, run

source .bashrc

to reload .bashrc and use powerline.sh in the existing konsole window.

If you want to go back to the default prompt, comment out the source powerline.sh line in ~/.bashrc by placing a # mark at the beginning of the line.

Read the contents of ~/bin/powerline.sh if you want to modify some aspects of the prompt.

konsole prompt using powerline fonts


Konsole, whether in Kubuntu 19.04 or Kubuntu 18.04, doesn't need fonts-powerline installed. But other terminals such as lxterminal and gnome-terminal need the package to get the triangles and the prompt to display nicely.