Personalizing My Shell Experience

The default bash prompt is mundane, I changed it.

This is the default in Kubuntu. It is long and ugly. I saw Kali’s shell and thought it was kinda cool.

Apart from the cool two-lines layout, there is syntax highlighting, the text turns red for unknown commands.

I searched on the Internet and ended up with something like this eventually:

The design is similar but offers more info. To get this prompt, just editing ~/.bashrc

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\e[36m\]┌─\[\e[01;30m\][\[\e[01;32m\]\u \[\e[01;34m\](\w)\[\e[01;30m\]] \[\e[00;32m\](\d \A)\n\[\e[00;36m\]└─\[\e[01;33m\](#`д´)ノ >\[\e[00m\] '
    PS1='${debian_chroot:+($debian_chroot)}┌─[\u (\w)] (\d \A)\n└─(#`д´)ノ > '

This is also the same for /root/.bashrc.

But it’s boring seeing only empty prompts, what if it displays a random quote every time I start a new session? There are 2 handy packages for that, fortune and cowsay.

Let’s not talk about their history, dive right into setting it up:

sudo apt install cowsay fortune

Then, insert the following lines somewhere near the top of the .bashrc file

fortune -s | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)

This will generate a random short quote, and have a random cow (character) say the quote. You can also twist a little and specify the cows to shuffle between

fortune -s | cowsay -f $(shuf -e tux suse vader-koala duck -n1).cow

This shuffles between tux, suse, koala vader and duck to say the quotes. Results look like this:

I was content with it for a while, then thought to myself: I want the syntax highlighting like Kali’s prompt.

I had no clue why using .bashrc from Kali did not work, but then I discovered Kali is not using bash anymore, but zsh.

I first installed zsh then oh-my-zsh.

sudo apt install zsh
sh -c "$(wget -O-"

The default oh-my-zsh prompt is rather… simple. It is not informative at all:

So I installed the zsh-syntax-highlighting and copied Kali’s .zshrc file over to modify

git clone ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Do the above again for root as well (sudo su), there are ways to symbolically link root’s .zshrc file but I install oh-my-zsh all over again for root anyway.

Installation is done, the rest is editing .zshrc, zsh’s prompt syntax is not the same as bash’s, it tooks me a while to understand what to change and what not to.

The example in bash above can be replicated with the following:

configure_prompt() {
    PROMPT=$'%F{050}┌─${debian_chroot:+($debian_chroot)─}${VIRTUAL_ENV:+($(basename $VIRTUAL_ENV))─}%F{243}[%B%F{223}%n%b %B%F{039}(%(6~.%-1~/…/%4~.%5~)%)%b%F{243}] %B%F{034}(%D{%a %b %d %Y %H:%M})%b\n%F{050}└─%B( ╯°□°)╯%b%F{reset} '

Again, do the same for root.