Beautifying the Bash Experience
Customizing the Command Prompt
There’s an insane number of things you can do to improve your Bash experience, one of which being changing up your command prompt.
There are couple of definitions to note within this section: the environmental variables
$PS1 refers to the primary command prompt, the one you see every time you open up a terminal running Bash.
$PS2 refers to the secondary command prompt, which is what you see when the terminal is expecting more input from you,
like when you use
I found the default primary command prompt to be a bit too long; it was eating up valuable screen space.
Hence, I set it to something shorter, my initials in bold green, and a dollar sign:
However, when I used the
p or the
Up Arrow key to access the previous command, it sometimes held a part of the previous line in the command line.
This did not affect the next command I ran, but it still bugged me.
Stuff that didn’t work
Based on StackOverflow’s answers, I enclosed my prompt in
\], to get
\[\e[1;32mKR$ \e[m\], but that was even worse.
Turns out, I didn’t read the answers correctly.
The solution is to change the command prompt, the value of
$PS1 by enclosing things that begin with
These are the nonprintable portions.
I had to split this up into two different sections, one for each nonprintable chunk.
Hence, I was left with
\[\e[m\] once I had added in those sequences.
The final solution was
Changing Appearance of Bash Layout
You can change the colors of how your directories, files and other things look when you list out the contents of a directory.
This information is stored in an environmental variable called
If you type
you’ll see a bunch of gunk.
If you want to play around before committing to anything, you can set another environmental variable to the value of
$LS_COLORS, and make any changes you want to
$LS_COLORS to check out the differences.
These changes will go away once you kill the current terminal.
If you want any changes to be permanent, just add a line to your
There are a gazillion options to customizing your setup, but a basic one could read as follows:
Let’s go through it bit by bit:
- Directories are bright cyan
- All PNG images are purple
- All executables are bright yellow
- Entries are colon-separated
My current settings for this variable are in my