Back to index

[Unfinished] Ricing your prompt (PS*)

Tags: linux, ricing, tutorial

Today, we will rice our prompt into something like this:

Prompt preview

Everybody who uses the terminal everyday loves to have a nice looking prompt, and I love to have one too! I have been trying a lot of different shells, just to see how does the prompt looks like.

Zsh and Fish is my favorite, they had a nice collection of themes where you can choose. I really like Powerlevel10k theme, it was made for Zsh and it’s look is just awesome.

Powerlevel10k preview

But they all had one problem: they are too sluggish.

Take Zsh for example, it’s themes were nice, but to startup or completing a process, it takes more than 0.2 seconds for the shell to become interactive. Even with the robbyrussell theme.

So I decided to make my own prompt.

The basics

  • ANSI escape codes We will use ANSI escape codes to colorize our prompt. We could use commands like tput, but that is too sluggish.

You can see the entire table of ANSI color codes on this gist. Or you can run this Bash script I found on the Internet.

Using this script will print out the whole color table using your terminal colors.

Script’s output

Let’s go

Try executing this command: echo $PS1. This command will print out a string, and that string is your current prompt.

[vnpower@vnpower ~]$ # I'm in Bash shell!
[vnpower@vnpower ~]$ echo $PS1
[\u@\h \W]\$

Then go to your shell’s rc file.