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
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!
Top comments (0)