I use the terminal a lot. I think itās primarily because my brother taught me how to use git when I started working in software development, and so Iāve gotten comfortable with it. Weāve covered git and terminal customization on this blog before:
- How I use git (on February 17th, 2018)
- Making sense of zsh (on October 29th, 2022)
- Git Tips & Tricks (Part 1) from my brother LoĆÆc himself (on March 10th, 2014)
And because I spend so much time in the terminal, I really enjoy when itās pretty and helpful. The default Terminal application on macOS always makes me cringe: itās so monochromatic and gloomy.
Iāve used a variety of shells and apps over the years: Git Bash, iTerm2, VSC embedded terminal, zsh⦠And Iāve recently discovered a new one,them all: Starship.
Whatās Starship
Starship is a minimal, fast, and customizable prompt for any shell. Itās built with compatibility in mind, itās written in Rust and itās highly configurable, with very sensible defaults. Itās genuinely an impressive little piece of software, and you have to learn about it if you havenāt yet.
Iām taking the liberty to hotlink the video from their homepage:
Getting started
I wonāt duplicate the installation guide, you can just read through it to get started. I will mention though that Starship approaches configuration in a very clean way:
- Separate configuration file: It uses its own configuration file instead of stuffing a bunch of things in your
.bashrcor.zshrcor whatever else. So youāll end up having your configuration at~/.config/starship.toml. - Perfect configuration format: It uses TOML as a format which is objectively the best configuration format there is.
- Useful out of the box: It has very sensible defaults, so you donāt need to spend hours configuring your prompt if all you want is something clean. Just adjust it as you go and need.
- Built modularly: Itās built in a modular way, so the configuration remains well organized and easy to adjust (Iām looking at you VS Code with your ungodly flat config).
My configuration
There are a lot of options to play with.
For instance, there is a āpromptā module to really customize the prompt itself, and there is a āPythonā module for everything specific to that language, and an AWS module for integration with the AWS CLI, and more. There are probably 50+ modules at the time of writing, covering most of the popular languages, frameworks, tools and more.
I like to rapidly see whether my last command exited successfully or not. Starship provides this off the bat, but I wanted to use a different character (and possibly different colors). Iāve configured it so that it uses the ā unicode character, in green or in red depending on the exit code:
[character] # See https://starship.rs/config/#character
success_symbol = '[ā](bold green)'
error_symbol = '[ā](bold red)'
I also like to see the current time next to my prompt, so I slot it on the right side, at the end of the line:
right_format = '$time'
[time] # See https://starship.rs/config/#time
disabled = false
format = '$time '
style = 'bright-black'
Iāve also adjusted the prompt for both Node.js and Rust since these are the 2 languages I work with:
[nodejs] # See https://starship.rs/config/#nodejs
disabled = false
format = "[$symbol($version )]($style)"
symbol = ""
[rust] # See https://starship.rs/config/#rust
disabled = false
format = '$symbol($version )'
[package] # See https://starship.rs/config/#package
disabled = false
format = '$symbol$version '
In case youāre curious, this is my complete configuration at the time of writing.
# Get editor completions based on the config schema
"$schema" = 'https://starship.rs/config-schema.json'
# Inserts a blank line between shell prompts
add_newline = false
format = '$directory$all$character'
right_format = '$time'
[character]
success_symbol = '[ā](bold green)'
error_symbol = '[ā](bold red)'
[aws]
disabled = true
[gcloud]
disabled = true
[azure]
disabled = true
[nodejs]
format = "$symbol($version )"
symbol = ""
disabled = false
[line_break]
disabled = true
[git_status]
disabled = true
[time]
disabled = false
format = '$time '
style = 'bright-black'
[cmd_duration]
min_time = 500
format = 'took [$duration](bold yellow) '
[rust]
format = '$symbol($version )'
disabled = false
[package]
disabled = false
format = '$symbol$version '
[directory]
truncation_length = 3
truncate_to_repo = true
use_logical_path = true
Nice details
Every time I play a bit more with Starship, Iām astounded at the level of care and detail that went into it.
For instance, the explain subcommand provides information about each component from your current prompt in order to better understand how to customize it. Calling starship explain right now in my websiteās directory shows this:
site on main v24.14.0 ā starship explain 10:33:47
Hereās a breakdown of your prompt:
"on main " (17ms) - The active branch of the repo in your current directory
"v24.14.0 " (63ms) - The currently installed version of NodeJS
"ā " (<1ms) - A character (usually an arrow) beside where the text is entered in your terminal
"site " (<1ms) - The current working directory
"10:33:47 " (<1ms) - The current local time
It also provides a lot of community presets which are basically ready-to-use TOML configuration files. Iāve played with the Catppuccin Powerline preset myself as a potential bold and colorful alternative.
Wrapping up
What was supposed to be a quick 20-minute article ended up taking me 2 hours because I couldnāt help but play with all the configuration options and redesign my prompt on a loop. š
As I said though, you donāt need to do that, you can largely roll with the default config and just fine tune whenever something bothers you. So if you havenāt tried Starship yet, you should. āØ