Starship Is A Minimal And Fast Shell Prompt Written In Rust

Over the years I've tried various fancy shell prompts, but I've always come back to the plain default username@host because I found the others too distracting and cluttered, or too slow for my taste.

Until I came across Starship, a cross-shell / cross-platform prompt. Using the defaults is simple but also very useful, providing extra information only when it's needed. It's highly customizable too, and you can make it look as fancy as you like, but I only made some minor changes for my needs: I made it show the prompt on a single line, and disabled the new line it adds above the start of the prompt, because that needs more scrolling.

I don't want to bore you with my personal experience though, so let me tell you more about Starship prompt and what it can do.

Starship prompt

Starship is not only minimal, always out of your way and only showing information when needed, but it's also fast and highly customizable, so you can have it look very fancy if you wish. Written in Rust, the prompt is supposed to work with most common shells on most common operating systems (includes configuration instructions for Bash, Fish, Zsh), featuring:

  • Makes use of a Powerline font to indicate various information (and the prompt) as symbol
  • The prompt turns red when the last command exists with non-zero code
  • Only shows the username if it's not the same as the logged-in user (and for root/ssh sessions obviously)
  • Integration with Git (shows the current Git branch and repository status), and can show the Node.js, Rust, Ruby, Python and Go version
  • Shows the version of the package in the current directory for cargo (Rust), npm (Node.js) and poetry (Python)
  • Shows the current battery level and status
  • Nix-shell environment detection
  • Shows the time it took to execute the last command if it exceeds the a configurable threshold
  • Has an indicator for jobs running in the background

Current configuration options include:

  • allows setting any character powerline character you wish instead of the default "❯ symbol, and change the color
  • set prompt order
  • configure the time it takes until Starship shows the time it took to run a command
  • set the current path truncation
  • show the time (disabled by default) with options to set the time format
  • set the way the battery levels are shown
  • set how the Git branch, state and status are shown
  • more

Read more about configuring Starship, and also check out its advanced configuration.

By default Starship prompt looks like this:

Starship promot default

If you wish to make it look like in the screenshot at the top of the article (have all the info on a single line, and disable the new line it adds above the prompt), create ~/.config/starship.toml and to this file add:

add_newline = false
disabled = true

Starship prompt is quite new, having its first release back in June, and it's under heavy development, with its configuration documentation page mentioning that many new configuration options will be available in the upcoming releases.

I'd also like to mention that the Starship devs are looking for contributors of all skill levels, so if you can and want to help, check out the Contributing section from its website.

Install Starship prompt

The Starship website does a good job at explaining how to install and set up this tool. Do remember to install a Powerline font if you haven't already (e.g. Fira Code).

In case you don't wish to install Starship using the methods presented on the Starship website (brew, cargo, etc.), you can download precompiled binaries from GitHub. You can install that by extracting the archive, then install the binary to /usr/local/bin (from the extracted folder) using:

sudo install starship /usr/local/bin/

via Hacker News