A starship is a rapid trans-shell construction using a rust rim. This is a minimal and incredibly fast terminal prompt. The main reason for its popularity is its customization. You can easily customize it using a TOML configuration file. If you’re switching to a different device or skin, just move the configuration file to the appropriate location, and your beautiful skin will automatically be ready.
A prerequisite
Before using Starship, you need to install geek font on your computer. The Nerd font is a beautiful combination of font and icons. go to Geek fonts and download your favorite. If you can’t decide, you can also preview the fonts programmingfonts.org.
In my case, I like the “Fira Code Nerd font”. Download the font and extract the content inside. You will get a folder called “FiraCode” and all the .otf and .ttf versions of the font.
To install this font, go to your terminal and run the following command.
# Creating the local font directory in your system mkdir ~/.local/share/fonts # Moving the extracted fonts to local font directory mv FiraCode ~/.local/share/fonts/
Now FiraCode Nerd font becomes available on your system. You can also install different types of fonts by following the guide above.
If you like to read an in-depth guide on installing fonts on the Linux desktop, check out this article on how to install fonts on Ubuntu.
Install Starship
To install starship, go to your home directory and run the following command.
curl -sS https://starship.rs/install.sh | sh
This command will download and install starship binary and add it to your path.
Install Starship on your shell
If you are using a bash shell, open your “~/.bashrc” file and paste this line of code at the end.
eval "$(starship init bash)"
If you’re using Zsh, open your “~/.zshrc” file instead and paste the above line of code at the end of it.
Now restart your console app. You will be greeted with the default spaceship prompt.
If you have a shell other than the two above, go to the starship documentation and find your preferred shell there.
Customize the starship
To customize your shell request, create a “starship.toml” file in your configuration directory.
# Creating your .config directory if not existed mkdir -p ~/.config # Creating a new starship.toml file touch ~/.config/starship.toml
You can also change the default location of the spaceship configuration file. To change the default location of your spaceship configuration file, add the STARSHIP_CONFIG
environment variable at the bottom of your “~/.bashrc” file.
export STARSHIP_CONFIG=~/example/non/default/path/starship.toml
Concept of module and variable
A module is a terminal-driven component that gives you contextual information about the underlying operating system. For example, Nodejs is a module hosted by Starship. When we add this module to the configuration file, it gives us various data points about the current installation of Nodejs in your environment.
The module gives this information in terms of variables. Variables are smaller subcomponents that contain information about the module. for example, version
is the “Nodejs” variable. When we call $version
Inside the Nodejs module, it gives us the currently installed version of Nodejs on your system. Variables are prefixed with $
symbol. A variable name can only contain letters, numbers and “_”.
Text groups and styles
Spaceship text groups contain 2 parts. The first part is enclosed below [ ]
symbol. This part is called a format string. We can add texts, variables and even nested text groups here.
The last part is circled under ( )
And this is called a style string. You can style the text group using this style string.
Let’s take an example.
[make_tech_easier](yellow bold)
will print the string “make_tech_easier” with bold text and yellow color.[👍 All Done](green)
It will print “👍 everything is done” in green.[a [b](green) c](red)
This is an example of nested text groups. It prints A and third in red and B in green
A few more style settings
- We can define different foregrounds and backgrounds for the text groups.
[ ](fg:red bg:blue)
Make the text font color red and background blue. - We can also use ANSI colors in the configuration file.
[ ](bold fg:27)
represent bold text with ANSI color 27 as the foreground color. - If you want to add your own hex color, that is also possible.
[ ](underline bg:#bf5700)
Gives underlined text with a bright orange background color.
Fast customization in Starship
The quick customization of the spaceship has 4 options. We can change these 4 options to customize the style of the prompts.
- format: It defines what the prompt will look like inside the terminal. You can set any design as a prompt.
- scan_timeout: Spaceship timeout for scanning files.
- timeout_command: Timeout for a command executed by a spaceship.
- add_newline: is a boolean. If set to true, it inserts a blank line between a shell directive.
A demo request customization file looks like this.
# Use custom format format = """ [┌───────────────────>](bold green) [│](bold green)$directory$rust$package [└─>](bold green) """ # Wait 10 milliseconds for starship to check files under the current directory. scan_timeout = 10 # Disable the blank line at the start of the prompt add_newline = false
Add your desired module
Now that you know the basics of a spaceship and how to customize it, you can add the desired module very easily. Remember that any module will work if the files and folder related to that module appear in the given path. Simply, the python module will only be visible if a python file exists within the current working directory.
Let’s add the python module to our starship configuration as a demonstration. Open your starship.toml file. Name to add [python] A new line to start the Python environment.
The Python module displays the information about the Python installation on your operating system or if any virtual environment is enabled. If you want to change the python icon and you want to display the name virtualenv, then the configuration file looks like this.
[python] symbol = "🐍 " pyenv_version_name = true
If you have both python2 and python3 installed, then you can specify the default python binary using the spaceship configuration file.
[python] # Only use the `python3` binary to get the version. python_binary = "python3"
Like this example, you can add any module you want and customize them according to your imagination.
How to add spaceship presets
If you don’t want to do all these customizations yourself, but want a nice terminal message out of the box, you can use presets. Presets are simply spaceship configuration files shared by other users. You can import the presets into your configuration file and have a nice looking terminal request in a moment.
You can explore the official presets on this page. The above terminal prompt is uploaded by a user and is available on the presets page. Now to make your console prompt look like this, open your ship’s configuration file and add this configuration to your file.
format = """ [←](#9A348E) $username [→](bg:#DA627D fg:#9A348E) $directory [→](fg:#DA627D bg:#FCA17D) $git_branch $git_status [→](fg:#FCA17D bg:#86BBD8) $c $elixir $elm $golang $haskell $java $julia $nodejs $nim $rust [→](fg:#86BBD8 bg:#06969A) $docker_context [→](fg:#06969A bg:#33658A) $time [→ ](fg:#33658A) """ # Disable the blank line at the start of the prompt # add_newline = false # You can also replace your username with a neat symbol like to save some space [username] show_always = true style_user = "bg:#9A348E" style_root = "bg:#9A348E" format = '[$user ]($style)' [directory] style = "bg:#DA627D" format = "[ $path ]($style)" truncation_length = 3 truncation_symbol = "…/" # Here is how you can shorten some long paths by text replacement # similar to mapped_locations in Oh My Posh: [directory.substitutions] "Documents" = "📄 " "Downloads" = "📥 " "Music" = "🎜 " "Pictures" = "📷 " # Keep in mind that the order matters. For example: # "Important Documents" = " " # will not be replaced, because "Documents" was already substituted before. # So either put "Important Documents" before "Documents" or use the substituted version: # "Important " = " " [c] symbol = "© " style = "bg:#86BBD8" format = '[[ $symbol ($version) ](bg:#86BBD8)]($style)' [docker_context] symbol = "🐳 " style = "bg:#06969A" format = '[[ $symbol $context ](bg:#06969A)]($style) $path' [elixir] symbol = "💧 " style = "bg:#86BBD8" format = '[[ $symbol ($version) ](bg:#86BBD8)]($style)' [elm] symbol = "🌳 " style = "bg:#86BBD8" format = '[[ $symbol ($version) ](bg:#86BBD8)]($style)' [git_branch] symbol = "☊" style = "bg:#FCA17D" format = '[[ $symbol $branch ](bg:#FCA17D)]($style)' [git_status] style = "bg:#FCA17D" format = '[[($all_status$ahead_behind )](bg:#FCA17D)]($style)' [golang] symbol = "🐹 " style = "bg:#86BBD8" format = '[[ $symbol ($version) ](bg:#86BBD8)]($style)' [haskell] symbol = "λ " style = "bg:#86BBD8" format = '[[ $symbol ($version) ](bg:#86BBD8)]($style)' [java] symbol = "☕ " style = "bg:#86BBD8" format = '[[ $symbol ($version) ](bg:#86BBD8)]($style)' [julia] symbol = "ஃ " style = "bg:#86BBD8" format = '[[ $symbol ($version) ](bg:#86BBD8)]($style)' [nodejs] symbol = "🔷 " style = "bg:#86BBD8" format = '[[ $symbol ($version) ](bg:#86BBD8)]($style)' [nim] symbol = "👑 " style = "bg:#86BBD8" format = '[[ $symbol ($version) ](bg:#86BBD8)]($style)' [rust] symbol = "🦀" style = "bg:#86BBD8" format = '[[ $symbol ($version) ](bg:#86BBD8)]($style)' [time] disabled = false time_format = "%R" # Hour:Minute Format style = "bg:#33658A" format = '[[ 🤍 $time ](bg:#33658A)]($style)'
Restart your terminal and your terminal prompt looks exactly like the prompt in the picture. You can search for more terminal prompts and try what suits you best. In the meantime, if you want to try some tips and tricks, this article should suit you best.
How to uninstall spaceship?
To uninstall starship, first, delete the starship configuration file.
rm ~/.config/starship.toml
Then remove the line you pasted during installation inside the “~/.bashrc” file.
Finally, uninstall the spaceship binary from your device.
sh -c 'rm "$(command -v 'starship')"'
Now restart your terminal and your prompt has been restored to the default style.
Common questions
How do I apply my current terminal prompt style to another device?
It’s very easy. Just copy your starship configuration file located at ~/.config/starship.toml
to the second device. Install the spaceship, restart the terminal, and you’re done.
What are the alternatives to a starship?
There are many space alternatives that you can find online. For zsh shell, oh-my-zsh is a very popular utility. Similarly, for fish shells, oh-my-fish is also a well-known tool that people use to personalize their shell request. Another one is Spaceship. This is a customizable zsh landing. Some other popular options are pure and A synth shell.
Is this article useful?
Sign up for our newsletter!
Our latest tutorials are delivered straight to your inbox