How to Customize Your Linux Terminal Prompt for a Better Workflow


Key Takeaways

  • Customizing your Bash prompt isn’t just fun, it can be useful too.
  • Showing simple system information is easy, but fancier prompts can get complex quickly.
  • Third-party plugins and scripts let you customize your prompt much more easily.



Are you sick of everyone else’s terminal prompt looking fancier than yours? They’re not just good-looking, but a well-customized prompt can increase your productivity too, and it’s easy to get started.


Why Customize Your Terminal Prompt?

This is more important if you’re frequently hopping between a bunch of different computers, either locally or remote, but a custom prompt can help you to quickly identify the computer you’re currently logged into. If you copy your ~/.bashrc or other config files to every computer you use, this won’t be the case, but a custom prompt can make quickly ID’ing your computer easier.

A custom prompt can tell you a lot more information than just what your username or hostname are. Your prompt can easily fill you in on your current working directory, whether the directory you’re in is version-controlled, and whether the files in that repository are up-to-date, for example. A subtle color change can even let you know whether the last command you ran was successful or not.


Speaking of colors, different people pay more or less attention to various colors. If you find the right combination, you may find that suddenly you’re able to instantly parse more information from your prompt without needing to study it. Some colors may have the opposite effect, so you may need to experiment a bit to find what works for you.

Of course, you shouldn’t dismiss the simple fun factor of customizing your terminal prompt. While there are plenty of practical reasons, it’s fine to simply enjoy looking at your terminal a little more. After all, chances are good that if you’re using Linux, you’re going to spend a non-trivial amount of time in the terminal, so it may as well look pretty.

How to Customize Your Bash Prompt

For this article, we’re going to focus on customizing the Bourne-Again Shell, better-known as Bash. While some of the approaches here are similar to what you would do for other shells, they typically use somewhat different syntax, so your results will vary. Make sure to consult the appropriate man pages or documentation if you’re using another shell.


Customizing your terminal involves setting the PS1 environment variable. You can set this temporarily inside your terminal, simply by typing something similar to the following:

PS1="Your wish is my command: " 

Of course, this isn’t exactly useful, so you probably want your terminal to give you some proper information. This is where you’ll need to do some thinking about what information you want to display, and how you want to format it.

Screenshot of a simple replacement command prompt in Bash.

We’ve got a list of essential special characters to know for Bash, which should help you get started. For more in-depth information, you’ll need to consult the prompt section of the Bash manual.

As an example, try something like the following:


PS1="\u@\H \W: " 

In the above example, \u prints your username, while \H prints your computer’s hostname and \W shows the working directory. This isn’t more information that you’ll find in your typical Bash prompt, but it shows how easy it can be to format information in your prompt.

Screenshot showing an example of an informative custom Bash prompt.

Colors and Special Characters

Adding colors to the Bash prompt isn’t as simple as it could be, unfortunately. You’ll need to take some already unwieldy ANSI color codes and slightly transpose them to format correctly in the prompt. To make things somewhat easier, here’s a list of commonly used colors:

  • Black: \033[30m
  • Red: \033[31m
  • Green: \033[32m
  • Yellow: \033[33m
  • Blue: \033[34m
  • Purple: \033[35m
  • Cyan: \033[36m
  • White: \033[37m


To colorize the above output, you’d use something like this:

PS1="\033[31m\u@\033[34m\H \033[36m\W: " 

The output is on the garish side, and may be tough to read depending on your background, but it works as an example of how to customize your colors. You can use similar ANSI escape characters to print special characters to the terminal.

Screenshot showing an example of ANSI color codes in the Bash prompt.

Making Your Prompt Permanent

After testing your prompt, it’s simple to keep your changes once you’ve settled on something you like. Simply add the prompt to the .bashrc file in your home directory. For example, to add the above colorized prompt to your Bash prompt, add the following to ~/.bashrc:

export PS1="\033[31m\u@\033[34m\H \033[36m\W: " 

Of course, there are also easier ways to customize your prompt.


Shortcuts to a Shinier Prompt

Okay, so by now you’re able to get started with some basic customizations, but what about the over-the-top configurations you’ve seen all over the internet? These are essentially just the same techniques we’ve used so far, but using special fonts known as Nerd Fonts that use Unicode characters to display icons.

While you could start using these yourself, you could also use an existing shell framework. One of the more popular examples is Oh-My-Zsh, which, as the name implies, is only available for the Z shell, also known as zsh. Since we’ve been focusing on Bash for this guide, this won’t work for us.

Fortunately, there are other options. Of of the best options at the time of this writing is Starship, which is a customizable prompt for any shell, including Bash. It’s written in rust for speed, and the instructions for getting started are simple. It’s even included in the repositories for certain Linux distributions like Arch, Void, and openSUSE.


Screenshot of the terminal after installing Starship for Bash.

Another popular option is Oh My Posh. Chances are, if there is something you wish you could do with Starship, you can with Oh My Posh. The downside is that this is a much deeper dive when it comes to learning the ins and outs of the system. That said, if you really want to get into tweaking your prompt, this offers the most flexibility.

What About Other Shells?

While we’re mainly focusing on the Bash prompt for this article, it’s not your only choice for the Linux terminal. For example, on macOS, Zsh has been the default shell for several major versions at this point. It has a few features that make it worth a look over Bash as well, depending on what you’re looking for.


To start, Zsh offers tab-completion. This is more powerful than the autocompletion you get with Bash, and it can be especially handy if you don’t remember your commands that well. Zsh also has a few features that can make customizing your prompt simpler without using a framework.

Another option is the Friendly Interactive Shell, also known as Fish. This makes both Bash and Zsh look positively spartan out of the box, as it’s absolutely feature packed right after you install it. This shell has a bunch of great features, but its main claim to fame is its auto-suggestions.

Checking Garuda Linux is running fish Shell


Unlike tab completion, Fish will start automatically populating commands you type with common options. If there is a certain file you open or a certain directory you move to frequently, you’ll see this suggested as soon as you start to type cd, for example. To ignore the suggestion, just keep typing the command you were going to type.

This feature gets more useful as you use the shell more. While you can it to Zsh via plugins, it’s built directly into fish.

To try out other shells, take a look at our guide to changing your shell with chsh.



Source link

Previous articleBitcoin hits first-ever $80,000 mark as traders bet on Trump’s White House return
Next articleBitcoin Surges Past $80,000 Amid Trump Victory Excitement – Bitcoin.com News