/statusline generates command with non-zero exit code and printf bug

Resolved 💬 2 comments Opened Feb 17, 2026 by krider2010 Closed Mar 18, 2026

Description

The /statusline slash command generates an inline shell command for settings.json that has two bugs:

1. Non-zero exit code

The generated command ends with:

[ "$style" != "default" ] && printf " \033[90m[$style]\033[0m"

When $style is "default" (the common case), the [ test returns exit code 1. Per the docs, "scripts that exit with non-zero codes or produce no output cause the status line to go blank." This means the statusline silently doesn't display for most users.

Fix: Append ; true or || true to ensure the command always exits 0.

2. printf format string injection

The generated command embeds variables directly in printf format strings:

printf "\033[33m  $branch$status \033[0m"
ctx=$(printf " \033[36m󰍛 ${remaining}%% \033[0m")
printf "\033[31m󰀵 $user\033[0m ... ${ctx} ..."

The ctx variable ends up containing a literal % (from the %% in the inner printf). When ${ctx} is expanded in the outer printf format string, that % is interpreted as a format specifier, producing:

bash: line 0: printf: `%': invalid format character

Fix: Use %s placeholders with variables as separate arguments:

printf "\033[33m  %s%s \033[0m" "$branch" "$status"

Steps to reproduce

  1. Run /statusline with any description (e.g., "show model, git branch, context, time")
  2. Observe the statusline doesn't appear
  3. Test the generated command manually — it exits with code 1 and prints a printf error

Expected behavior

The generated command should exit 0 and use safe printf format strings.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗