Change Terminal Prompt

Aimed Guendouz
3 min readJun 20, 2023

--

Terminal default prompt is usually boring without color or emoji but you can change it to whatever you want.

This task depend on your shell, below common shell and how to change the prompt for every one.

if you don’t know which shell do you use run this command

echo $SHELL

check that all the necessary characters are supported by running this

echo "\ue0b0 💀"

If the command does not display the characters correctly use the font fira code or hack and use the utf-8 encoding, if this didn’t work try installing a new terminal or reinstalling the current one.

ZSH

If the character are displayed, add this line at the end of the file .zshrc and open a new terminal window :

prompt=$'%K{blue}%F{\e]11;?\a}\ue0b0%F{\e]11;?\a} %n💀%m %K{178}%F{blue}\ue0b0 %(6~.%-1~/…/%4~.%5~) %F{178}%K{\e]11;?\a}\ue0b0%b%K{reset}%F{reset} '

The prompt will look like this:

If you want to build your own prompt use:

%K{color} for background color
%F{color} for front color
%B for bold
%k or %K{reset} reset background color to default
%f or %F{reset} reset front color to default
%b reset bold
\e]11;?\a is the terminal background color
%n for username
%m for hostname
%(6~.%-1~/…/%4~.%5~) for working directory
\ue0b0 for the triangle character
you may want to use these characters: 💀 or ㉿

BASH

If the character are displayed, add this line at the end of the file ~/.bashrc and open a new terminal window :

PS1=$'\033[44;30m\ue0b0\033[0m\[\e[44m\[\e]11;?\a\] \u💀\h \[\e[48;5;178m\e[34m\]\ue0b0 \w \[\e[38;5;178m\033[49m\ue0b0\[\e[1m\]\[\e[0m\] '

The prompt will look like this

If you want to build your own prompt use:

\u for username
\h for hostname
\w for working directory
\ue0b0 for the triangle character
you may want to use these characters: 💀 or ㉿

FISH

If the character are displayed, create the file ~/.config/fish/functions/fish_prompt.fish and add the following content to it:

function fish_prompt
echo -e "\033[44;30m\033[0m\e[44m\e]11;?\a $USER💀$(hostname) \e[48;5;178m\e[34m $(pwd | sed "s|^$HOME|~|") \e[38;5;178m\033[49m\e[1m\e[0>
end

Reopen the terminal and the prompt will look like this:

KSH

If the character are displayed, add this line at the end of the file ~/.kshrc if it doesn’t exist create it:

PS1=$'\033[44;30m\033[0m\e[44m\e]11;?\a $USER"💀"$(hostname) \e[48;5;178m\e[34m $(pwd | sed "s|^$HOME|~|") \e[38;5;178m\033[49m\e[1m\e[0m '

Reopen the terminal and the prompt will look like this:

Learn more about linux in our website: https://linuxtutor.github.io/

Thank you for reading, comment if you have any question or other shell.

--

--