Kurt Schambacha3chron
Blog

Starship

Startship is a "cross-shell prompt", a cool way to customize the look of your shell, but also good to add some helpful information, for example the current git branch, Node or Python versions, and much more...

Installation

Starship is aviable for many operating systems:

  • Android
  • BSD
  • Linux
  • macOS
  • Windows

and even more shells:

  • Bash
  • Cmd
  • Elvish
  • Fish
  • Ion
  • Nushell
  • PowerShell
  • Tcsh
  • Xonsh
  • Zsh

If you can't find yourself at this list, check out the Advanced Installation.


As the Installation Guide is quite good, I will only show the guides for Linux and MacOS.

For any other installation options, or shell, please check the Starship Installation Guide

  1. Install Starship
Linux
curl -sS https://starship.rs/install.sh | sh
MacOS
# same as linux, or:
brew install starship
  1. Configure the shell to start Starship

Add these lines to your shell's configuration file:

shelllocationcommand
bash~/.bashrceval "$(starship init bash)"
fish~/.config/fish/config.fishstarship init fish
zsh~/.zshrceval "$(starship init zsh)"
Elvish~/.elvish/rc.elveval (starship init elvish)
Ion~/.config/ion/initrceval $(starship init ion)

When you open a new shell, you should now see the new prompt.

  1. Configure Starship

For customization, check out the Starship Config information.

All Starship configuration is done it the following file (you need to create it first):

~/.config/starship.toml

For more information about TOML, see their Github Repo

My Starship Configuration

~/.config/starship.toml
# custom format
format = '''
[┌── $shell─────────────── $memory_usage ──> $nodejs $python](bold green)
[│](bold green)$sudo$username$hostname$localip$directory$character$git_branch$git_metrics$cmd_duration
[└ $battery ─>](bold green) '''
 
#format = '$all$directory$character'
 
# Wait 10 milliseconds for starship to check files under the current directory.
scan_timeout = 10
command_timeout = 500
add_newline = true
 
 
 
[shell]
fish_indicator = 'fish'
bash_indicator = 'bash'
unknown_indicator = 'unknwn'
style = 'cyan bold'
disabled = false
 
[username]
style_user = 'green bold'
format = ' [$user@]($style)'
disabled = false
show_always = true
 
[sudo]
style = 'bold red'
format = ' [sudo](bold red)'
disabled = false
 
[python]
symbol = ''
format = 'Python [$version [\($virtualenv\)](dimmed yellow)](bold dimmed green)'
pyenv_version_name = true
detect_files = ['requirements.txt', '__init.py__', 'setup.py']
detect_extensions = ['py']
detect_folders = []
 
[nodejs]
format = 'Node [$version](bold dimmed green)'
 
[memory_usage]
disabled = false
threshold = -1
format = '$ram_pct'
symbol = ''
style = 'bold dimmed green'
 
[localip]
ssh_only = false
format = '[@$localipv4](bold yellow) '
disabled = false
 
[hostname]
ssh_only = false
ssh_symbol = 'ssh:'
format = '[$ssh_symbol](bold dimmed green)[$hostname](bold dimmed green)'
trim_at = ''
disabled = false
 
[git_metrics]
disabled = false
format = ' [+$added](bold green)[-$deleted](bold red)'
 
[git_branch]
format = '[$branch(:$remote_branch)]($style)'
style = 'bold purple'
 
[fill]
symbol = '-'
style = 'bold green'
 
# time of command
[cmd_duration]
min_time = 500
format = ' [$duration](bold yellow)'
 
[directory]
fish_style_pwd_dir_length = 5
disabled = false
truncation_length = 5
truncation_symbol = '…/'
style = 'bold blue'
 
# promt char
[character]
success_symbol = '[-->](bold green)'
error_symbol = '[-->](bold red)'
 
# Disable the package module, hiding it from the prompt completely
[package]
disabled = true
 
 
# battery
[battery]
 
full_symbol = '^'
charging_symbol = '+'
discharging_symbol = '-'
 
[[battery.display]]
threshold = 20
style = 'bold red'
 
[[battery.display]]
threshold = 50
style = 'bold orange'
 
[[battery.display]]
threshold = 100
style = 'bold green'

0

0