4

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.

3

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.

  • Nice! However, you do need fonts-powerline for the triangles. – vanadium Sep 6 at 12:46
  • @vanadium I thought so as well but I checked again, I don't have fonts-powerline installed on Kubuntu 18.04 and still have the triangles. I also checked Lubuntu 19.04. There too, fonts-powerline is absent and the triangles are present. I don't know how the triangles are still being generated. – Justice for Monica Sep 6 at 12:51
  • @vanadium, even apt list --installed | grep -i powerline comes up empty. Maybe it's needed on a GNOME-based system? – Justice for Monica Sep 6 at 12:56
  • 1
    Could be. I had to install the fonts to have a good outcome. – vanadium Sep 6 at 12:59
4

The appearance of the Bash command prompt is controlled by the environmental variable $PS1. By changing this environmental variable, you change the appearance of the prompt.

You can see the current setting of this variable with the command:

echo $PS1

The prompt can be changed with the command

PS1="<string representing new format>"

To change permanently, change the definition of PS1 in the file .bashrc in your home folder. That script is run automatically when you open a terminal, and includes a section where PS1 is defined.

man bash may instruct you about the syntax of the string that defines the prompt format. It may be easier, though, to start with some tutorials like here on How-To Geek or nixcraft.

To implement effects as appear in your screenshot, you may want to consider Powerline, a set of script developed to provide a more fancy look to the vim editor, but including scripts to change among others the bash terminal. Powerline can be installed with sudo apt install powerline, and can then be used according to the documentation.

For more details regarding installation and use, refer to How can I install and use powerline plugin?, and in particular the answer of Schycken, because earlier answers have become obsolete.

  • 1
    I think OP wants something like powerline which apparently requires fonts-powerline installed. – Justice for Monica Sep 6 at 6:56
  • @steeldriver Thank you for the comment. I updated the answer – vanadium Sep 6 at 12:32
-3

The simplest way: https://ohmyz.sh/

And choose a theme like this one: https://github.com/robbyrussell/oh-my-zsh/wiki/Themes#agnoster

ZSH theme

  • 6
    How does installing a Zsh theme help getting a graphical Bash prompt? – Jörg W Mittag Sep 6 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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