Blog Archive

Liquid Prompt is an adaptive, smart prompt for Bash and Zsh. It can display various useful information on the shell prompt, only when it's needed, like the battery status when it's discharging over a given threshold, an up arrow if using an HTTP proxy, the number of detached sessions (screen or tmux) and more.

Liquid Prompt can be configured so if you don't want certain information to show up either because you don't need it or because Liquid Prompt simply displays too much of it for your taste, you can easily disable some info from showing up by editing its configuration file.

Here's some of the info Liquid Prompt may (depending on the configuration and if it's needed in a given context) display:

the average of the processors load, if it is over a given limit, with a colormap that becomes more and more noticeable with increasing load;

the error code of the last command, if it has failed in some way;

a green ⏚ if the battery is charging, above the given threshold, but not charged, a yellow ⏚ if the battery is charging and under threshold, a yellow ⌁ if the battery is discharging but above threshold, a red ⌁ if the battery is discharging and under threshold;

the current directory in bold, shortened if it takes too much space, while preserving the first two directories;

a green colon if the user has write permissions on the current directory, a red one if he has not;

current time as numerci values or an analog clock;

the number of detached sessions (screen or tmux), if there are any;

the number of attached sleeping jobs (when you interrupt a command with Ctrl-Z and bring it back with fg), if there are any;

the number of attached running jobs (commands started with a &), if there are any;

the current host, if you are connected via a telnet connection (in bold red) or SSH (either a blue hostname or different colors for different hosts);

a green @ if the connection has X11 support, a yellow one if not;

an up arrow if an HTTP proxy is in use;

the name of the current branch if you are in a version control repository (git, mercurial, subversion, bazaar or fossil), in green if everything is up to date, in red if there is changes, in yellow if there is pending commits to push;

the number of added/deleted lines (git) or files (fossil), if changes have been made and the number of pending commits, if any;

a red star if there is some untracked files in the repository;

the current user, in bold yellow if it is root, in light white if it is not the same as the login user;

a tag associated to the current shell session (you can easily add any prefix tag to your prompt, by invoking prompt_tag MYTAG);

a smart mark: ± for git directories, ☿ for mercurial, ‡ for svn, ‡± for git-svn, ⌘ for fossil, $ or % for simple user, a red # for root;

Below you can see more examples of what Liquid Prompt can display (image via Liquid Prompt GitHub page):

Install Liquid Prompt

1. To install Liquid Prompt, firstly install Git. In Ubuntu / Debian, use the following command:

sudo apt-get install git

Then get the code and install Liquid Prompt using the following commands:

Alternatively, if you cannot use Git for some reason (behind a firewall that doesn't allow this, etc.), you can download the code from HERE - extract it in your home directory, rename it to ".liquidprompt" (don't forget the dot in front of the folder name) and then run the last command above to copy the configuration file into ~/.config.

2. Then, open ~/.bashrc (or ~/.zshrc for Zsh) with a text editor - I'll use Gedit for the command below: