How to Customise and Pimp Your Bash Prompt in Linux

Pimp your Linux Terminal

If you use Linux, you’re going to spend a decent amount of time working in the terminal. Why wouldn’t you want it to reflect your style and the theme of your desktop? Through the work of the open-source community, there are loads of different options to trick out your command line experience in Linux, and they’re all simple to use.

Terminator Terminal Emulator

One of the first and easiest things that you can do to change up your command line in Linux is to switch your terminal emulator.

When you open the “terminal” on your distribution, you’re really opening a terminal emulator. A terminal emulator just emulates the old dumb terminals that were physically connected to Unix servers. They were just a screen and a keyboard that allowed you to interact with the server from a distance in the absence of networking.

That’s enough of a history lesson. It all just amounts to the fact that the terminal emulator is a piece of software, and like just about every other vital piece of software on Linux, there are loads of options. You’re not stuck with the one your distribution shipped with.

There’s nothing wrong with the terminal emulators that come with Linux distributions, and more specifically, desktop environments. Many people prefer options like Gnome Terminal and Konsole. In fact, plenty of non-KDE users like Konsole. It supports a load of features and tends to be very stable.

If you’re looking for something different, there are even more options out there. Terminator, Termite, and URXVT are all excellent.

Terminator is a rather large and full-featured option that supports splitting the terminal window to do more than one thing in the same place.

Termite and URXVT are both more minimal. They’re better-suited for people who want to heavily customize their terminal emulator.

Gruvbox Linux terminal color scheme

No matter which terminal emulator you’re using, you can change the color scheme to anything that you want.

The more full-featured terminal emulators usually have a “Settings” menu that allows you to make some minor color adjustments, but they aren’t nearly as good as some of the color schemes out there.

The Solarized color scheme was designed to be both visually appealing and easy on the eyes. It was painstakingly engineered to use specific colors that maintain contrast but aren’t too harsh. Solarized has both light and dark themes that you can rotate based on the time of the day or preference.

Base16 is another whole set of options. It provides a methodology of using sixteen colors to establish a complete color layout for your terminal. There is a whole list of possible color schemes that follow the Base16 pattern.

Maybe you want something a little retro. Gruvbox uses colors inspired by the 70s but in a very modern way. The theme looks stylish and pleasing to the eye. Like Solarized, it also has both light and dark options.

Design a Linux Terminal Scheme with Terminal.sexy

If you want something more custom, you can build it with Terminal.sexy. It follows the Base16 style guidelines but lets you customize our colors in real time. Then, you can export the configuration that you’ve created to match whichever terminal emulator you’re using.

Terminal emulators all have their own configuration files in unique locations. It’s best to look up where your configuration file resides.

Customized Bash prompt

The command prompt is the bit of text that greets you every time you open up a terminal emulator. It usually gives you your username, the name of your computer, and maybe the directory that you’re in, but you can customize it, too.

The prompt is stored in a variable called PS1. You don’t have to worry too much about the technical side of it, but you should know that you can change the value of PS1.

There’s a file in your home directory called .bashrc. That file controls the things that the Linux shell will run every time you start a terminal emulator. If you set the value of PS1 in this file, it will apply every time you open a terminal.

Bash uses escape sequences to represent the things that you might want to display. For example \u stands for your username. Here are some of the more useful ones.

  • \u = username
  • \h = shortened hostname
  • \H = hostname with domain
  • \d = date
  • \t = 24 hour time
  • \T = 12 hour time
  • \w = full working directory
  • \W = current folder
  • \e = ASCII escape to use ASCII characters
  • \n = new line

You can string any number of these together to make your own custom prompt. Here are more useful and interesting bash prompts.

Bash doesn’t limit you to the default colors either. You can use the ASCII escape sequence to use ASCII colors. Colors look something like this: \[\e[32m\]. The 32m part determines the color. The colors run 30 to 37. Your color scheme determines the colors that the numbers correspond to.

You can add a 1 or a 4 in front of the color to specify bold or underlined text. It looks like this: \[\e[1;33m\].

Everything that follows one of these color blocks takes on the properties that it dictates. It will continue that way until another block changes it. To return to the default, use 0 in the color definition. Take a look at the whole thing together.

There are a ton of ways that you can customize your Bash terminal in Linux. It’s hard to point you in a single direction since so much of this is preference. Experiment and look around for additional options. Beware, customizing your terminal emulator can be incredibly addictive.

7 comments

  1. I find it interesting that those experienced in Linux try very hard to impress on prospective Linux users and newbies that most tasks can be accomplished using GUI. Then I read statements such as “If you use Linux, you’re going to spend a decent amount of time working in the terminal. “. Which is it?

    I realize that knowing the command line is helpful and that the command line provides a finer granularity but is it actually necessary for the apocryphal ‘average user’ to know it to enjoy Linux?

    • I can give you my experience. I used a Windows since at least 3.1 (even used Vista) and still do occasionallt for work. I (gradually) switched to Ubuntu about 5 years, though.
      I don’t use the command prompt much. In my experience, if you use a computer like a typical office drone or weekend gamer lile I do, you’ll rarely need to, and the times you do, you can just look up what you want/need to online and type that in without really understanding it. Kinda ile following a recipe.
      But the terminal is powerful and fast, so if you want to, there is a lot you can do through it to make things–even officey, gamey, “normal” things–faster and easier.
      So, if you just want to use your machine like a Mac or Windows replacement, you will rarely (but still probably sometimes) use it. If you want to supe your machine up or take it off-roading, then you will.
      HTH

    • It really depends on how you plan on using Linux. A person who only wants to browse the web, send emails, listen to music/watch videos, and use LibreOffice can get by just fine without ever touching the command line.

      However, if you plan on doing any of the things that “power users” and “enthusiasts” tend to do like customizing your work space, gaming, installing new hardware, or anything along those lines, you will find yourself in the command line. As a long-time Linux user, I tend to recommend the command line to anyone even remotely interested in their computer. There’s a certain zen to it, once you get past the fact that you’re typing instead of clicking.

      • Don’t get me wrong. I am not bashing bash or CLI. One should know how to use, and use, any tool available.

        I suppose it can be said that any user that willingly switches from Windows/Mac to Linux is no longer an ‘average user.’ I also suppose that any user who finds his/her way to Make Tech Easier can no longer be considered an ‘average user.’

        ” There’s a certain zen to it”
        That’s better way of putting it than “Makes one feel l33t.’ :-)

  2. I have two naive users on Linux for, must be ten years now, basically using it for writing, web, mail, photography, streaming media recently. Neither one of them has ever used the command line except when I talked them through doing something, and that was probably only once or twice between them, and to save me time more than from necessity.

  3. It is not necessary to know or use the command line in Linux. Lots of people have YouTube videos and they show you their machines, but never once mention their command line usage. Linux has “grown up” over the years and now there’s no real need to use the command line for anything. Until…..you find an app that’s not working properly, or there’s some error message you get when trying to use your favorite program. Its times like that……when you need to “Bash” your way around or through a problem that knowing the command line is useful. As for “average users” I agree with Dragonmouth…..once you enter the world of Linux you cease to be an average user. Even if you never open a terminal or type one command, you’re on a different level simply because you’ve taken the leap into the world of open source, and once you get there?…..there’s really no turning back. I have yet to hear of someone who jumped into Linux and decided to go BACK to Windows / Mac. Oh don’t get me wrong…I’m sure there’s thousands of people who have done that…..but you just hardly ever HEAR of it! LoL!

    As for me, I made the move to Linux in 2002 / ’03 with Fedora and I have never looked back. Were there times when I was frustrated?……stuck with an issue that I couldn’t resolve right away?……teased and ridiculed sometimes by the more veteran Linux users? Yes. Yes. And Yes…..but going through those “growing pains” has given me an insight as to where to now look when a problem arises (is it a problem in /etc/var?…..or maybe /dev/sdb1….or maybe just a bad character in a .config file…) These things don’t come naturally to a Windows user, because all they know is “double-click”….wait for install to complete….and click “Finish” when its done!….LoL! (Sorry I know I shouldn’t be all “snobbish”…my apologies!)

  4. I’d love to run a retro looking terminal, is there a more automated/script way of doing it?

    I found a great video (‘Ubuntu C64 Sytle’), that seems to show that it’s possible to just run a script, but it’s in German, so not sure…

    I haven’t tried LlamaTerminal, but I did try installing cool-retro-term, but it brought my poor pi down to it’s knees!

    Is there any way to do this,
    https://www.maketecheasier.com/customise-terminal-os-x/

    but in Linux (debian, ubuntu, anything??)

Comments are closed.

Sponsored Stories