Elevate your CLI experience: Starship (upd.)

Posted Jan 03, 2024. Updated Jan 06, 2024  ‐  2 min read

New prompt for a Nushell

Yesterday, I wrote an introduction article about Nushell. Today, I would like to write about Starship, a nice addon to this shell (and many others). It is a customizable prompt that enhances your experience while using Nushell.

Starship developers recommends to install Nerd Fonts to have icons in font. Most likely, you will be able to find terminal font that you use on this list. You can also try to use a Font Patcher Script utility to add icons to your favourite font.

Installation

Let's install Starship.

cargo install --force starship
starship init nu | save -f ~/.starship.nu
use ~/.starship.nu

If you use different OS than Linux, please have look at documentation on how to install Starship.

Basic configuration

To start Starship when your Nushell starts, please add "use ~/.starship.nu" at the end of your config file ~/.config/nushell/config.nu .

By default Starship provides you information about branch, software version and compiler version in project directory. There are a lot of options that you can configure in this prompt.

For now I decided to use one of the presets - Gruvbox Rainbow. You can enable it by executing the following command.

starship preset gruvbox-rainbow -o ~/.config/starship.toml

Here is how my shell prompt looks like now.

Starship

There are a lot of things to configure both on Starship and Nushell. It's tempting to work on a custom color scheme.

Configuration (2024-01-06)

In Starship you can customize the prompt to your needs. I decided to update Gruvbox Rainbow theme to the theme colors that I specified in "Elevate your CLI experience: Nushell".

It was not a complicated task. You can customize theme by editing ~/.config/starship.toml.

Here are changes that I made.

format = """
[](color_ruby)\
$os\
$username\
[](bg:color_sapphire fg:color_ruby)\
$directory\
[](fg:color_sapphire bg:color_emerald)\
$git_branch\
$git_status\
[](fg:color_emerald bg:color_sapphire)\
$c\
$rust\
$golang\
$nodejs\
$php\
$java\
$kotlin\
$haskell\
$python\
[](fg:color_sapphire bg:color_emerald)\
$docker_context\
[](fg:color_emerald bg:color_amethyst)\
$time\
[ ](fg:color_amethyst)\
$line_break$character"""

palette = 'practicalrs'

[palettes.practicalrs]
color_onyx = '#040404'
color_ruby = '#c02310'
color_emerald = '#257d10'
color_sapphire = '#00327b'
color_aquamarine = '#3b96bf'
color_amethyst = '#703b6c'
color_topaz = '#bc7800'
color_diamond = '#d0d9d7'

[os]
disabled = false
style = "bg:color_ruby fg:color_diamond"

[os.symbols]
Windows = "󰍲"
Ubuntu = "󰕈"
SUSE = ""
Raspbian = "󰐿"
Mint = "󰣭"
Macos = "󰀵"
Manjaro = ""
Linux = "󰌽"
Gentoo = "󰣨"
Fedora = "󰣛"
Alpine = ""
Amazon = ""
Android = ""
Arch = "󰣇"
Artix = "󰣇"
CentOS = ""
Debian = "󰣚"
Redhat = "󱄛"
RedHatEnterprise = "󱄛"

[username]
show_always = true
style_user = "bg:color_ruby fg:color_diamond"
style_root = "bg:color_ruby fg:color_diamond"
format = '[ $user ]($style)'

[directory]
style = "fg:color_diamond bg:color_sapphire"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"

[directory.substitutions]
"Documents" = "󰈙 "
"Downloads" = " "
"Music" = "󰝚 "
"Pictures" = " "
"Developer" = "󰲋 "

[git_branch]
symbol = ""
style = "bg:color_emerald"
format = '[[ $symbol $branch ](fg:color_diamond bg:color_emerald)]($style)'

[git_status]
style = "bg:color_emerald"
format = '[[($all_status$ahead_behind )](fg:color_diamond bg:color_emerald)]($style)'

[nodejs]
symbol = ""
style = "bg:color_sapphire"
format = '[[ $symbol( $version) ](fg:color_diamond bg:color_sapphire)]($style)'

[c]
symbol = " "
style = "bg:color_sapphire"
format = '[[ $symbol( $version) ](fg:color_diamond bg:color_sapphire)]($style)'

[rust]
symbol = ""
style = "bg:color_sapphire"
format = '[[ $symbol( $version) ](fg:color_diamond bg:color_sapphire)]($style)'

[golang]
symbol = ""
style = "bg:color_sapphire"
format = '[[ $symbol( $version) ](fg:color_diamond bg:color_sapphire)]($style)'

[php]
symbol = ""
style = "bg:color_sapphire"
format = '[[ $symbol( $version) ](fg:color_diamond bg:color_sapphire)]($style)'

[java]
symbol = " "
style = "bg:color_sapphire"
format = '[[ $symbol( $version) ](fg:color_diamond bg:color_sapphire)]($style)'

[kotlin]
symbol = ""
style = "bg:color_sapphire"
format = '[[ $symbol( $version) ](fg:color_diamond bg:color_sapphire)]($style)'

[haskell]
symbol = ""
style = "bg:color_sapphire"
format = '[[ $symbol( $version) ](fg:color_diamond bg:color_sapphire)]($style)'

[python]
symbol = ""
style = "bg:color_sapphire"
format = '[[ $symbol( $version) ](fg:color_diamond bg:color_sapphire)]($style)'

[docker_context]
symbol = ""
style = "bg:color_emerald"
format = '[[ $symbol( $context) ](fg:color_diamond bg:color_emerald)]($style)'

[time]
disabled = false
time_format = "%R"
style = "bg:color_diamond"
format = '[[  $time ](fg:color_diamond bg:color_amethyst)]($style)'

[line_break]
disabled = false

[character]
disabled = false
success_symbol = '[](bold fg:color_emerald)'
error_symbol = '[](bold fg:color_ruby)'
vimcmd_symbol = '[](bold fg:color_emerald)'
vimcmd_replace_one_symbol = '[](bold fg:color_amethyst)'
vimcmd_replace_symbol = '[](bold fg:color_amethyst)'
vimcmd_visual_symbol = '[](bold fg:color_topaz)'

Here is the end result.

Starship

Prompt customization in Starship is a simple task. You can find my Starship config file in prs-configs repository.

Tools usage disclosure. I'm not a native English speaker. I use the following tools to improve my wording: Google Translate, Grammarly, and Hemingway Editor. These tools use artificial intelligence. I use them only to improve my writing, not to generate content.