DEV Community

Cover image for Make Your Terminal Better with Starship
Souhail Segni
Souhail Segni

Posted on

Make Your Terminal Better with Starship

In terminal customization, Starship stands out as a powerful, cross-shell prompt that elevates your command-line experience. Lightweight, fast, and highly customizable, Starship lets you personalize your prompt to suit your workflow. This blog will guide you through configuring your starship.toml file to unleash the full potential of Starship.

Introduction
A well-configured terminal prompt can significantly enhance your productivity by providing critical information at a glance. Starship allows you to customize every aspect of your prompt, from the color scheme to the information displayed, making it an indispensable tool for developers and sysadmins alike.

Getting Started with Starship
To get started, you first need to install Starship. The installation process varies depending on your operating system:

Linux
Using Shell Script (Recommended):
curl -sS https://starship.rs/install.sh | sh
Debian/Ubuntu:
sudo apt install starship
Fedora:
sudo dnf install starship
Arch Linux:
sudo pacman -S starship

macOS:
brew install starship
Windows:
Install Scoop if not already installed.
scoop install starship

Once installed, you need to configure your shell to use Starship. Add the following line to your shell configuration file (e.g., ~/.bashrc, ~/.zshrc, etc.):
eval "$(starship init bash)"

Replace bash with your shell of choice (zsh, fish, etc.).

The starship.toml file is where all your configuration settings reside. This file allows you to customize the prompt modules, colors, and display logic. Here's an example configuration file with some common customizations:
here is an example of starship.toml code

[πŸ™‹](bg:#73a6f5)\
$username\
[Ιͺᴘ](bg:#ff0000)\
$custom\
$uptime\
$git_branch\
$git_status\
[☁️ ](fg:#1B5E20 bg:#16537e)\
$aws\
$time\
$battery\
$directory\
$status\
[➑️  ️](fg:#2c3e50)\
"""
command_timeout = 5000
scan_timeout = 70

[username]
show_always = true
style_user = "bold bg:#008744"
style_root = "bold bg:#182C61"
format = "[ ➑  $user ]($style)"
disabled = false
[custom.network]
command = "hostname -I | awk '{print $1}'"
format = "[ $output ]($style)"
style = "bold blue bg:#ffffff"
when = "hostname -I"

[directory]
style = "bold bg:#0292ff"
format = "[πŸ“‚ $path]($style)"
truncation_length = 3
truncation_symbol = "…/"
[battery]
full_symbol = "πŸ”‹βš‘"
charging_symbol = "⚑"
discharging_symbol = "πŸ”Œ"
format = "[$symbol $percentage ]($style) [$status]($style)"  # Status adds info like 'Charging' or 'Discharging'

[[battery.display]]  # For low battery (0-20%)
threshold = 20
style = "bold black bg:#fb0000"

[[battery.display]]  # For medium battery (20-60%)
threshold = 60
style = "bold black bg:#fb0000"

[[battery.display]]  # For high battery (60-100%)
threshold = 100
style = "bold black bg:#fb0000"

[c]
symbol = "πŸ‡¨"
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[python]
symbol = "🌐"
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"


[elixir]
symbol = " "
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[elm]
symbol = " "
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[git_branch]
symbol = "☯"
style = "bg:#23dfdc fg:#000000"
format = "[ $symbol $branch ]($style)"

[git_status]
style = "bg:#16a085 fg:#000000"
format = "[$all_status$ahead_behind ]($style)"

[golang]
symbol = " "
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[gradle]
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[aws]
symbol = "☁️"
style = "bold fg:#ffa500 bg:#16537e"
format = "[ AWS:eu-west-1 ]($style)"

[haskell]
symbol = " "
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[java]
symbol = "ξ‰– "
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[julia]
symbol = " "
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[nodejs]
symbol = ""
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[nim]
symbol = "ξ™· "
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[rust]
symbol = ""
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[scala]
symbol = " "
style = "bg:#1B5E20"
format = "[ $symbol ($version) ]($style)"

[docker_context]
symbol = " "
style = "bg:#2980b9"
format = "[ $symbol $context ]($style) $path"

[time]
disabled = false
time_format = "%r" # Hour:Minute:Seconds AM/PM Format
style = "bold bg:#ecde23 fg:#000000"
format = "[⏰ $time ]($style)"

[cmd_duration]
style = "bold bg:#1A237E"
min_time = 500
format = "[ took:$duration]($style)"

[status]
style = "bold black bg:#ffffff"
symbol = "β›”"
success_symbol = "βœ…"
format = "[$symbol $common_meaning$signal_name$maybe_int ]($style)"
map_symbol = true
disabled = false
Enter fullscreen mode Exit fullscreen mode

Conclusion
Starship is a versatile tool that offers immense flexibility in terminal prompt customization. By configuring Starship.toml, you can tailor your command line experience to meet your specific needs, enhancing both productivity and aesthetic appeal.

Dive into the Starship documentation for more detailed configuration options and customize your terminal to make it truly yours.
https://starship.rs/

Happy customizing!

starship.toml #basch #Terminal

Top comments (0)