Add sync-repos and WezTerm theming to claude-profile

claude-profile now:
- Syncs all repos (git pull --ff-only) before starting a session
- Emits WezTerm user-var escape sequences to trigger profile themes
- Resets terminal theme on session exit via trap

New script sync-repos pulls latest for all git repos under ~/dev/claude
with --dryrun support and color status output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul O'Reilly
2026-03-18 18:44:43 +13:00
parent 8e978fef9d
commit 2055926100
2 changed files with 115 additions and 6 deletions

View File

@@ -10,6 +10,29 @@ set -euo pipefail
DEFAULT_DIR="$HOME/.claude"
PROFILE_PATTERN="$HOME/.claude-*"
# Emit a WezTerm user-var escape sequence to trigger profile-based theming.
# WezTerm decodes the base64 value and fires a 'user-var-changed' event.
# Safe to call in non-WezTerm terminals — the escape sequence is silently ignored.
set_wezterm_profile() {
local profile_name="$1"
printf '\e]1337;SetUserVar=%s=%s\a' CLAUDE_PROFILE "$(printf '%s' "$profile_name" | base64)"
}
# Reset WezTerm theme when the script exits (e.g., Claude session ends)
reset_wezterm_profile() {
printf '\e]1337;SetUserVar=%s=%s\a' CLAUDE_PROFILE "$(printf '%s' '_reset' | base64)"
}
trap reset_wezterm_profile EXIT
# Sync all repos before starting a session
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SYNC_SCRIPT="${SCRIPT_DIR}/sync-repos"
if [[ -x "$SYNC_SCRIPT" ]]; then
echo "Syncing repos..."
"$SYNC_SCRIPT" || echo "Warning: some repos failed to sync (continuing anyway)"
echo ""
fi
# Gather profiles
profiles=()
for dir in $PROFILE_PATTERN; do
@@ -23,8 +46,10 @@ if [[ ${1:-} ]]; then
target="$HOME/.claude-$1"
if [[ -d "$target" ]]; then
export CLAUDE_CONFIG_DIR="$target"
set_wezterm_profile "$1"
echo "Using profile: $1 ($target)"
exec claude "${@:2}"
claude "${@:2}"
exit $?
else
echo "Profile '$1' not found. Create it with: mkdir -p $target" >&2
exit 1
@@ -58,16 +83,15 @@ selected="${options[$((choice - 1))]}"
if [[ "$selected" == "default" ]]; then
echo "Using default profile ($DEFAULT_DIR)"
export CLAUDE_CONFIG_DIR="$DEFAULT_DIR"
set_wezterm_profile "default"
else
target="$HOME/.claude-$selected"
echo "Using profile: $selected ($target)"
export CLAUDE_CONFIG_DIR="$target"
set_wezterm_profile "$selected"
fi
#set -uo pipefail
# Load the context
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
CONTEXT_LOADER="${SCRIPT_DIR}/context-load"
if [[ ! -x "$CONTEXT_LOADER" ]]; then
@@ -78,7 +102,7 @@ fi
context="$("$CONTEXT_LOADER")"
if [[ -n "$context" ]]; then
exec claude --append-system-prompt "$context" "$@"
claude --append-system-prompt "$context" "$@"
else
exec claude "$@"
claude "$@"
fi