dotfiles/starship/starship.toml

"$schema" = 'https://starship.rs/config-schema.json'
 
palette = 'harp_midnight'
 
command_timeout = 1300
 
format = """
$hostname\
${custom.dir_parent}${custom.dir_leaf}\
$git_branch$git_status\
$kubernetes$aws${custom.terraform}$helm\
$nodejs\
$cmd_duration\
$line_break$character"""
 
[hostname]
ssh_only = true
style = "dim"
format = "[@$hostname]($style) "
 
[directory]
disabled = true
 
[custom.dir_parent]
when = "true"
shell = ["/bin/sh"]
command = '''d="$PWD"; case "$d" in "$HOME"|/) exit 0;; esac; d="${d%/*}"; [ -z "$d" ] && { printf /; exit 0; }; case "$d" in "$HOME") printf '~/'; exit 0;; "$HOME"/*) d="~/${d#"$HOME"/}";; esac; printf %s "$d" | awk -F/ '{n=NF; if(n<=1){printf "%s/",$0; next} pre=(n>2)?"…/":""; printf "%s%s/%s/",pre,$(n-1),$n}' '''
style = "dim"
format = "[$output]($style)"
 
[custom.dir_leaf]
when = "true"
shell = ["/bin/sh"]
command = '''case "$PWD" in "$HOME") printf '~';; /) printf /;; *) printf %s "${PWD##*/}";; esac '''
style = "bold accent"
format = "[$output]($style) "
 
[git_branch]
symbol = " "
style = "kw"
format = "[$symbol$branch]($style) "
 
[git_status]
style = "warn"
ahead = "⇡${count}"
behind = "⇣${count}"
diverged = "⇕⇡${ahead_count}⇣${behind_count}"
staged = "✚${count}"
modified = "…${count}"
untracked = "?${count}"
stashed = "≡"
conflicted = "!"
deleted = "✘${count}"
renamed = "»${count}"
format = "([$all_status$ahead_behind]($style)) "
 
[kubernetes]
disabled = false
symbol = " "
style = "fn"
format = "[$symbol$context( ·$namespace)]($style) "
 
[[kubernetes.contexts]]
context_pattern = "^(?:.*[_/])?(?P<c>[^_/]*[Pp][Rr][Oo][Dd][^_/]*)$"
context_alias = "$c"
style = "bold red"
 
[[kubernetes.contexts]]
context_pattern = "^(?:.*[_/])?(?P<c>[^_/]+)$"
context_alias = "$c"
 
[aws]
symbol = " "
style = "fn"
format = '[$symbol$profile(\($region\))( $duration)]($style) '
 
[terraform]
disabled = true
 
[custom.terraform]
detect_extensions = ["tf", "tofu", "hcl", "tfplan", "tfstate"]
detect_folders = [".terraform"]
shell = ["/bin/sh"]
symbol = " "
command = '''
tool=
if   [ -f .opentofu-version ]; then tool=tofu
elif [ -f .terraform-version ]; then tool=terraform
elif [ -f .terraform.lock.hcl ]; then
  grep -qF registry.opentofu.org .terraform.lock.hcl 2>/dev/null && tool=tofu
  [ -z "$tool" ] && grep -qF registry.terraform.io .terraform.lock.hcl 2>/dev/null && tool=terraform
fi
# Terragrunt: honor terraform_binary from the nearest root.hcl/terragrunt.hcl up the tree
if [ -z "$tool" ]; then
  d="$PWD"
  while :; do
    for f in "$d/root.hcl" "$d/terragrunt.hcl" "$d/terragrunt.hcl.json"; do
      [ -f "$f" ] || continue
      tb=$(sed -n 's/.*terraform_binary[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' "$f" | head -1)
      case "$tb" in
        tofu|*/tofu) tool=tofu; break 2 ;;
        terraform|*/terraform) tool=terraform; break 2 ;;
      esac
    done
    [ "$d" = / ] && break
    d=${d%/*}; [ -z "$d" ] && d=/
  done
fi
[ -z "$tool" ] && command -v terraform >/dev/null 2>&1 && tool=terraform
[ -z "$tool" ] && command -v tofu >/dev/null 2>&1 && tool=tofu
[ -z "$tool" ] && exit 0
command -v "$tool" >/dev/null 2>&1 || exit 0
ver=
case "$tool" in
  terraform) if [ -f .terraform-version ]; then ver=$(head -1 .terraform-version); else vf="${TFENV_ROOT:-$HOME/.tfenv}/version"; if [ -f "$vf" ]; then ver=$(head -1 "$vf"); else ver=$(terraform version 2>/dev/null | head -1 | sed -E 's/.*v([0-9][0-9.]*).*/\1/'); fi; fi ;;
  tofu) if [ -f .opentofu-version ]; then ver=$(head -1 .opentofu-version); else ver=$(tofu version 2>/dev/null | head -1 | sed -E 's/.*v([0-9][0-9.]*).*/\1/'); fi ;;
esac
ws=${TF_WORKSPACE:-$(cat .terraform/environment 2>/dev/null || echo default)}
case "$tool" in tofu) out=tofu;; *) out=tf;; esac
[ -n "$ver" ] && out="$out $ver"
[ "$ws" != default ] && [ -n "$ws" ] && out="$out ($ws)"
printf '%s' "$out"
'''
style = "dim"
format = "[$symbol$output]($style) "
 
[helm]
symbol = " "
style = "dim"
format = "[$symbol$version]($style) "
 
[nodejs]
symbol = ""
style = "dim"
format = "[$symbol $version]($style) "
 
[cmd_duration]
min_time = 2000
style = "comment"
format = "[$duration]($style) "
 
[line_break]
disabled = false
 
[character]
disabled = false
success_symbol = "[❯](bold accent)"
error_symbol = "[❯](bold red)"
vimcmd_symbol = "[❮](bold green)"
vimcmd_replace_one_symbol = "[❮](bold num)"
vimcmd_replace_symbol = "[❮](bold num)"
vimcmd_visual_symbol = "[❮](bold type)"
 
[palettes.harp_midnight]
base = "#17171f"
surface = "#131320"
bar = "#10101c"
line = "#232330"
sel = "#2c2942"
fg = "#c4c2d4"
dim = "#7c7a92"
comment = "#56556a"
accent = "#9b8ae8"
kw = "#beb0f0"
str = "#9a98b4"
fn = "#b0aede"
type = "#a8a6c4"
num = "#c8b6f2"
op = "#86849c"
red = "#c2868a"
green = "#84b07a"
warn = "#cbb98a"