blob: 3e5e6fb119e1510ab256f49f9f76df9cc01c7a8c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/bin/sh
# Claude Code status line — mirrors the zsh prompt from ~/.zshrc
# PROMPT: [%D %*] $WHO $HOST:${PWD/#$HOME/~} %(?..[%?] )$NEWLINE%#
# RPROMPT: ${vcs_info_msg_0_} (format: "on %b")
#
# Wired via the statusLine entry in .claude/settings.json; make install
# symlinks this file to ~/.claude/statusline-command.sh on every machine.
input=$(cat)
cwd=$(echo "$input" | jq -r '.cwd')
# Replace $HOME prefix with ~. The replacement tilde must be escaped:
# unquoted, bash tilde-expands it straight back to $HOME.
home="$HOME"
display_dir="${cwd/#$home/\~}"
# Git branch from cwd (mirrors vcs_info RPROMPT "on %b")
branch=$(git -C "$cwd" symbolic-ref --short HEAD 2>/dev/null)
git_part=""
[ -n "$branch" ] && git_part=" on $branch"
date_part=$(date "+%y-%m-%d %H:%M:%S")
user_part=$(whoami)
# uname -n, not hostname: Arch doesn't ship hostname by default (inetutils).
host_part=$(uname -n)
printf "%s %s %s:%s%s" "[$date_part]" "$user_part" "$host_part" "$display_dir" "$git_part"
|