Brief: A cross-shell prompt that makes it easy to customize and configure the Linux terminal prompt, if you care too much about the looks of your terminal.
While I’ve already covered a few tips to help you customize the looks of your terminal, I also came across suggestions for an interesting cross-shell prompt.
Starship: Tweak your Linux Shell Prompt Easily
Starship is an open-source project that’s written in Rust to help you set up a minimal, fast, and customizable shell prompt.
No matter whether you’re using bash, fish, PowerShell on Windows or any other shell, you can utilize Starship to customize the appearance.
Do note that you do have to go through its official documentation to be able to perform advanced configuration for everything you like but here I will include a simple sample configuration to get a head start along with some key information about Startship.
Starship focuses on giving you a minimal, fast, and useful shell prompt by default. It even records and shows the time taken to perform a command as well. For instance, here’s a screenshot:
Not just limited to that, it is also fairly easy to customize the prompt to your liking. Here’s an official GIF that shows it in action:
Let me help you set it up. I am using bash shell on Ubuntu to test this out. You can refer to the steps I mention, or you can take a look at the official installation instructions for more options to install it on your system.
Key Highlights of Starship
- Cross-shell support
- Ability to add custom commands
- Customize git experience
- Customize the experience while using specific programming languages
- Easily customize every aspect of the prompt without taking a hit on performance in a meaningful way
Installing Starship on Linux
Installing Starship requires downloading a bash script from the internet and then run the script with root access.|
If you are not comfortable with that, you may use snap here:
sudo snap install starship
Note: You need to have Nerd Font installed to get the complete experience.
To get started, ensure that you have curl installed. You can install it easily by typing in:
sudo apt install curl
Once you do that, type in the following to install Starship:
curl -fsSL https://starship.rs/install.sh | bash
This should install Starship to usr/local/bin as root. You might be prompted for the password. Here’s how it would look:
Add startship to bash
As the screenshot suggests, you will get the instruction to set it up in the terminal itself. But, in this case, we need to add the following line at the end of our bashrc user file:
eval "$(starship init bash)"
To add it easily, simply type in:
Now, navigate to the end of the file by scrolling down and add the line at the end of the file as shown in the image below:
Once done, simply restart the terminal or restart your session to see the minimal prompt. It might look a bit different for your shell, but more or less it should be the same by default.
Once you set it up, you can proceed customizing and configuring the prompt. Let me show you an example configuration that I did:
Configure Starship Shell Prompt: The Basics
To get started, you just need to make a configuration file (TOML file) inside a .config directory. If you already have one, you should simply navigate to the directory and just create the configuration file.
Here’s what you have to type to create the directory and the config file:
mkdir -p ~/.config && touch ~/.config/starship.toml
Do note that this is a hidden directory. So, when you try to access it from your home directory using the file manager, make sure to enable viewing hidden files before proceeding.
From this point onwards, you should refer to the configuration documentation if you want to explore something you like.
For an example, I configured a simple custom prompt that looks like:
To achieve this, my configuration file looks like this:
It is a basic custom format as per their official documentation. But, if you do not want a custom format and simply want to customize the default prompt with a color or a different symbol, that would look like:
And, the configuration file for the above customization looks like:
Of course, that’s not the best-looking prompt one can make but I hope you get the idea.
You can customize how the directory looks by including icons/emojis, you can tweak the variables, format strings git commits, or while using specific programming languages.
Not just limited to that, you can also create custom commands to use in your shell to make things easier or comfortable for yourself.
You should explore more about in their official website and its GitHub page.
If you just want some minor tweaks, the documentation might prove to be too overwhelming. But, even then, it lets you achieve a custom prompt or a minimal prompt with little effort that you can apply on any common shell and any system you’re working on.
Perosnally, I don’t think it’s very useful but several readers suggested it and it seems people do love it. I am eager to see how you customize the Linux terminal for different kinds of usage.
Feel free to share what you think about it and if you like it, in the comments down below.