Skip to content

Instantly share code, notes, and snippets.

@pythoninthegrass
Last active April 26, 2024 20:24
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save pythoninthegrass/faff76c2f571c57126e793733aae167d to your computer and use it in GitHub Desktop.
Save pythoninthegrass/faff76c2f571c57126e793733aae167d to your computer and use it in GitHub Desktop.
Starship prompt setup
# SOURCES
# https://starship.rs/config
# https://starship.rs/presets/nerd-font.html#configuration
# DEBUG via:
# starship explain
# STARSHIP_LOG=trace
"$schema" = 'https://starship.rs/config-schema.json'
# Timeout for commands executed by starship (ms)
command_timeout = 1000
# newline between commands
add_newline = true
# ! opt-in for individual modules (e.g., aws, docker, gcloud, nodejs, python)
# standalone format to get os glyph on ps1 line,
# prompt character below
format = """
$os$username$hostname:$directory$git_branch$git_status$git_commit$python$cmd_duration
$character
"""
# Replace the "❯"
[character]
success_symbol = "[λ](green)"
error_symbol = "[λ](red)"
[username]
style_user = "green bold"
style_root = "red bold"
format = "[$user]($style)"
disabled = false
show_always = true
[hostname]
ssh_only = false
format = "[@$hostname](green bold)"
disabled = false
# truncation length works backwards (i.e., cwd > parent > parent ...)
[directory]
truncation_length = 15
truncation_symbol = "…/"
truncate_to_repo = true
[git_branch]
truncation_length = 25
truncation_symbol = ''
[git_status]
ahead = '⇡${count}'
diverged = '⇕⇡${ahead_count}⇣${behind_count}'
behind = '⇣${count}'
staged = '[++\($count\)](green)'
[git_commit]
commit_hash_length = 4
[env_var.SHELL]
variable = "SHELL"
default = "unknown shell"
disabled = true
[cmd_duration]
min_time = 500
format = '[$duration](bold yellow)'
# Show python version starting with venv
[python]
python_binary = ["./venv/bin/python", "python3", "python", "python2"]
[aws]
disabled = true
[docker_context]
disabled = true
[gcloud]
disabled = true
[nodejs]
disabled = true
[os]
format = '[$symbol](bold white)'
disabled = false
[os.symbols]
Alpaquita = " "
Alpine = " "
Amazon = " "
Android = " "
Arch = " "
Artix = " "
CentOS = " "
Debian = " "
DragonFly = " "
Emscripten = " "
EndeavourOS = " "
Fedora = " "
FreeBSD = " "
Garuda = "󰛓 "
Gentoo = " "
HardenedBSD = "󰞌 "
Illumos = "󰈸 "
Linux = " "
Mabox = " "
Macos = " "
Manjaro = " "
Mariner = " "
MidnightBSD = " "
Mint = " "
NetBSD = " "
NixOS = " "
OpenBSD = "󰈺 "
openSUSE = " "
OracleLinux = "󰌷 "
Pop = " "
Raspbian = " "
Redhat = " "
RedHatEnterprise = " "
Redox = "󰀘 "
Solus = "󰠳 "
SUSE = " "
Ubuntu = " "
Unknown = " "
Windows = "󰍲 "

Setup Starship Prompt

Install Nerd Fonts

# macos
brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font

# linux (arch)
mkdir -p ~/.local/share/fonts
git clone --filter=blob:none --sparse https://github.com/ryanoasis/nerd-fonts
cd nerd-fonts/
git sparse-checkout add patched-fonts/Hack
cd patched-fonts/Hack/
find . -name "*.ttf" -exec cp {} ~/.local/share/fonts/ \;

Install Starship

sh -c "$(curl -fsSL https://starship.rs/install.sh)"

Copy config

cp starship.toml ~/.config/starship.toml

Install Shell Color Script

git clone https://gitlab.com/dwt1/shell-color-scripts.git
cd shell-color-scripts
sudo make install

Add to .bashrc

# starship
colorscript -e random # crunch
eval "$(starship init bash)"

Further reading

Starship

Derek Taylor / Shell Color Scripts · GitLab

How to get the most out of your Terminal | by Reagan McFarland | Medium

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment