Ever notice the
$ in front of every command in this tutorial series? Surely, the text that appears before your command input is different. Here, we'll show you how to customize this by changing the
The variable that stores the configuration is
$PS1 (short for Prompt Statement). To check your own
$PS1, use the
$ echo $PS1 \n\[\033[1;34m\]\W$\[\033[0m\]
On my personal computer, I use this setting. It outputs the current working directory, then a
$ symbol, all in blue text. It then sets the user's font color to default.
Here are a list of characters that act as variables that you can use for your prompt statement. They are all preceded by the escape key (
Let's say we want current time (
\@), the current working folder (
\w), followed by a greater than symbol (
>). Remember to use single quotes to prevent shell expansion!
$ export 'PS1=\@ \w >' 05:01 PM ~/snipcademy/code >
It looks great! Although it would look even better with some color.
To add color, we must make use of the ANSI escape code, \e. This tells the terminal not to interpret the sequence, but to interpret it as a command.
Here are the values that we may use for text font decoration.
Since this is a sequence of non-printing characters, we enclose them in
Here is a list of colors you can choose from:
$ export PS1='\[\e[0;36m\]\@ \w >'
To specify the color that the user types, we add another color to the end of our
$ export PS1='\[\e[0;36m\]\@ \w >\[\e[1;37m\]' 06:32 PM ~/snipcademy >
To add a text background color, use a similar method but with these sequences.
$ export PS1='\[\e[0;36m\]\@ \w >\[\e[1;37m\] \[\e[0;44m\]' 06:32 PM ~/snipcademy > User input text here.
You may also customize your settings so that you can move the cursor line around.
To save your prompt, place it in your .bashrc file.
Linux for Beginners doesn't make any assumptions about your background or knowledge of Linux. You need no prior knowledge to benefit from this book. You will be guided step by step using a logical and systematic approach. As new concepts, commands, or jargon are encountered they are explained in plain language, making it easy for anyone to understand.$ Check price
Relieve spasms, tight muscles, trigger points and pressure points with the Body Back Buddy! This trigger point massage is designed to help you self-message any area of your body - especially those that are hard to reach. Keeping your muscles relaxes and out of contraction is importan in helping to reduce pain and prevent muscle injury.$ Check price