Page 47 - Raspberry Pi as a Foundation for Boosting Computer and Technology Literacy
P. 47
Customizing the system and the shell 3.4
Figure 3.22 Finding the PS1 variable in the .bashrc file
Figure 26 Editing the .profile file
we are looking for is “PS1”, which contains the customization options
for the current user’s command prompt (Figure 3.22).
nano .bashrc
Then, locate the first occurrence of the “PS1” variable, comment it
out (in case we would like to change it back to the original) as per Fig-
ure 3.23. Subsequently, add the following variable definition beneath it
(ensuring it remains a single line):
PS1=’\[\e[38;5;110;1m\]\u\[\e[38;5;150m\]@\
[\e[38;5;210m\]\h \[\e[0;38;5;246;3m\]\w \
[\e[0;38;5;150;1m\]> \[\e[0m\]’
After saving and exiting the file, close and reopen the terminal or
execute:
source .bashrc
Now, we should be greeted with a more colourful command prompt.
The variable may seem like a lot of gibberish, and it can be challenging
to modify it by hand, let alone create one from scratch. Therefore, it
is a good idea to use online tools, such as a bash prompt generator
( https://bash-prompt-generator.org/).
Figure 3.23 Replacing the PS1 variable
47