diff --git a/dotfiles/statusline-command.sh b/dotfiles/statusline-command.sh index 74112b1..8c81de5 100644 --- a/dotfiles/statusline-command.sh +++ b/dotfiles/statusline-command.sh @@ -18,19 +18,26 @@ IFS=$'\t' read -r current_dir model total_input total_output context_size used_p total_tokens=$(( (total_input + total_output) / 1000 )) context_limit_k=$(( context_size / 1000 )) -cost_formatted=$(LC_NUMERIC=C awk "BEGIN { - cents = int($cost_usd * 100 + 0.5) - if (cents < 100) printf \"%d¢\", cents - else printf \"\$%.2f\", $cost_usd -}") +cost_formatted=$(LC_NUMERIC=C awk -v cost="$cost_usd" 'BEGIN { + cents = int(cost * 100 + 0.5) + if (cents < 100) printf "%d¢", cents + else printf "$%.2f", cost +}') user=$(whoami) host=$(hostname -s) +# Lange Pfade kürzen, damit die Statusline nie umbricht (sonst gerät der +# claude-code-Renderer aus dem Tritt, weil er 1 Zeile am unteren Rand erwartet). +display_dir=$current_dir +if [ ${#display_dir} -gt 25 ]; then + display_dir=".../$(basename "$(dirname "$current_dir")")/$(basename "$current_dir")" +fi + git_branch="" if [ -n "$current_dir" ] && git -C "$current_dir" rev-parse --git-dir > /dev/null 2>&1; then branch=$(git -C "$current_dir" branch --show-current 2>/dev/null) - [ -n "$branch" ] && git_branch=" \033[33m($branch)\033[00m" + [ -n "$branch" ] && printf -v git_branch ' \033[33m(%s)\033[00m' "$branch" fi chroot_prefix="" @@ -38,7 +45,6 @@ if [ -r /etc/debian_chroot ]; then chroot_prefix="($(cat /etc/debian_chroot))" fi -printf "${chroot_prefix}\033[32m${user}@${host}\033[00m:\033[34m${current_dir}\033[00m${git_branch}" -printf " \033[90m|\033[00m \033[36m${model}\033[00m" -printf " \033[90m|\033[00m \033[35m${total_tokens}K/${context_limit_k}K (${used_percent}%%)\033[00m" -printf " \033[90m|\033[00m \033[33m${cost_formatted}\033[00m" +printf '%s\033[32m%s@%s\033[00m:\033[34m%s\033[00m%s \033[90m|\033[00m \033[36m%s\033[00m \033[90m|\033[00m \033[35m%dK/%dK (%d%%)\033[00m \033[90m|\033[00m \033[33m%s\033[00m' \ + "$chroot_prefix" "$user" "$host" "$display_dir" "$git_branch" \ + "$model" "$total_tokens" "$context_limit_k" "$used_percent" "$cost_formatted"