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.
This book approaches system administration in a practical way and is an invaluable reference for both new administrators and experienced professionals. It details best practices for every facet of system administration, including storage management, network design and administration, email, web hosting, scripting, and much more.$ Check price
Ever feel achy from sitting crunched up on your computer table? Try lying down with these optical glasses that allow you to work on your laptop while lying flat on your back. This is the perfect solution with those with limited mobility or those who wish to prevent neck cramps and back strains.$ Check price