The terminal prompt. The command line interface. The CLI. Thecurl -sS https://starship.rs/install.sh | shell.
Not the most exciting things, right?
To most Linux users, the terminal is a tool to accomplish important work. It's not a playground or something used to make others jealous of your setup.
That doesn't mean the prompt has to be boring or uninformative.
Also: This terminal app uses AI to help you understand the command line
Starship aims to be the better prompt for Linux and MacOS users. This shell replacement is minimal, fast, and highly customizable. Starship is an open-source tool designed to enhance your prompt with at-a-glance information while presenting a sleek and efficient appearance.
I started using Starship some time ago and have found it to be a great replacement for the default on most Linux distributions (and even MacOS).
Let me show you how to install it and then how to customize it.
What you'll need: To get Starship running, you'll need a running instance of either Linux or MacOS. The installation on either platform can be achieved using the same simple method.
The first thing you must do is log into your desktop and open your default terminal app. On Linux this could be any number of terminal apps and on MacOS it's probably just the default (which is, aptly named, Terminal.app).
There's only one command to run for the Starship installation and that is:
curl -sS https://starship.rs/install.sh | sh
After running the command, you'll be asked to OKy the installation location (just type "y") and then type your user password. The installation will start and finish much faster than you think, so don't worry if you blink your eyes and have your prompt returned to you... the installation was successful.
If you receive an error on MacOS, it's most likely because the /usr/local/bin directory doesn't exist. If that's the case, create it and then re-run the installation command. You can create that directory with:
sudo mkdir /usr/local/bin
Although Starship has been successfully installed, you'll notice your prompt hasn't changed. That's because we have to configure your shell to use it. On Linux, open the necessary file with:
nano ~/.bashrc
At the bottom of that file, add the following line:
eval "$(starship init bash)"
Save and close the file.
To enable Starship on MacOS, you must first create the .zsch file with the command:
nano ~/.zsch
In that file, add the following:
eval "$(starship init zsch)"
Save and close the file.
Before you close your current terminal window, open another instance and make sure that Starship has been successfully installed and running. If so, your terminal will look something like this:
~
>
The customization of Starship is done in the starship.toml file. By default, that file does not exist, so we'll create it with:
nano ~/.config/starship.toml
The configuration of Starship is done in blocks, and there are blocks for certain things such as global settings, character, battery, time, directory, git, language-specific modules, container and cloud modules, OS, username, and hostname. I will show you how to configure a Starship prompt with my custom layout. You can then change that customization to meet your needs.
Also: How to generate random passwords from the Linux command line
You customize your prompt by adding or modifying different modules in the format string. The basic layout is:
format = """
$directory$git_branch$character
"""
First, let's configure a global layout, followed by layouts for directories and even battery status (which only works on a device that uses a battery). These configuration options are added to the starship.toml file.
My global section looks like this:
format = """
[