claude updates
This commit is contained in:
@@ -1,32 +1,34 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
# NixOS has no /bin/bash; use env so the shebang resolves on all hosts.
|
||||
input=$(cat)
|
||||
|
||||
# Extract values from JSON input
|
||||
MODEL=$(echo "$input" | jq -r '.model.display_name // "Claude"')
|
||||
DIR=$(echo "$input" | jq -r '.workspace.current_dir // "~"')
|
||||
DIR_NAME="${DIR##*/}"
|
||||
CONTEXT_USED=$(echo "$input" | jq -r '.context_window.used_percentage // 0')
|
||||
COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')
|
||||
|
||||
# Get git repo root path (abbreviated with ~) and branch/PR info
|
||||
# Machine hostname (bash sets HOSTNAME; fall back to /etc/hostname)
|
||||
HOST="${HOSTNAME:-$(cat /etc/hostname 2>/dev/null || echo host)}"
|
||||
|
||||
# Git repo root (abbreviated ~/projects -> p/) and branch/PR info
|
||||
GIT_INFO=""
|
||||
REPO_PATH=""
|
||||
if git -C "$DIR" rev-parse --git-dir > /dev/null 2>&1; then
|
||||
REPO_ROOT=$(git -C "$DIR" rev-parse --show-toplevel 2>/dev/null)
|
||||
# For worktrees, get the main repo root instead of the worktree path
|
||||
# For worktrees, use the main repo root instead of the worktree path
|
||||
MAIN_GIT_DIR=$(git -C "$DIR" rev-parse --git-common-dir 2>/dev/null)
|
||||
if [ -n "$MAIN_GIT_DIR" ] && [[ "$MAIN_GIT_DIR" == /* ]]; then
|
||||
REPO_ROOT=$(dirname "$MAIN_GIT_DIR")
|
||||
fi
|
||||
# Abbreviate ~/projects/ to p/
|
||||
REPO_PATH=" | ${REPO_ROOT/#$HOME\/projects\//p/}"
|
||||
REPO_PATH="${REPO_ROOT/#$HOME\/projects\//p/}"
|
||||
BRANCH=$(git -C "$DIR" branch --show-current 2>/dev/null)
|
||||
if [ -n "$BRANCH" ]; then
|
||||
PR_NUMBER=$(GIT_DIR="$DIR/.git" GIT_WORK_TREE="$DIR" gh pr view --json number -q '.number' 2>/dev/null)
|
||||
if [ -n "$PR_NUMBER" ]; then
|
||||
GIT_INFO=" | $BRANCH (#$PR_NUMBER)"
|
||||
GIT_INFO="$BRANCH (#$PR_NUMBER)"
|
||||
else
|
||||
GIT_INFO=" | $BRANCH"
|
||||
GIT_INFO="$BRANCH"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -34,4 +36,29 @@ fi
|
||||
# Format cost (force C locale so the decimal separator is always ".")
|
||||
COST_FMT=$(LC_NUMERIC=C printf "%.2f" "$COST")
|
||||
|
||||
echo "YOLO$REPO_PATH$GIT_INFO | [$MODEL] | \$$COST_FMT | ${CONTEXT_USED}%"
|
||||
# Colors
|
||||
RESET=$'\033[0m'
|
||||
C_HOST=$'\033[1;36m' # bold cyan — distinguishes the machine
|
||||
C_PATH=$'\033[32m' # green
|
||||
C_BRANCH=$'\033[33m' # yellow
|
||||
C_MODEL=$'\033[35m' # magenta
|
||||
C_COST=$'\033[32m' # green
|
||||
SEP=$'\033[90m | \033[0m' # dim separator
|
||||
|
||||
# Context % colored by fill level: green < 50, yellow < 80, red >= 80
|
||||
CTX_INT=${CONTEXT_USED%.*}; CTX_INT=${CTX_INT:-0}
|
||||
if [ "$CTX_INT" -ge 80 ] 2>/dev/null; then
|
||||
C_CTX=$'\033[31m'
|
||||
elif [ "$CTX_INT" -ge 50 ] 2>/dev/null; then
|
||||
C_CTX=$'\033[33m'
|
||||
else
|
||||
C_CTX=$'\033[32m'
|
||||
fi
|
||||
|
||||
out="${C_HOST}${HOST}${RESET}"
|
||||
[ -n "$REPO_PATH" ] && out="${out}${SEP}${C_PATH}${REPO_PATH}${RESET}"
|
||||
[ -n "$GIT_INFO" ] && out="${out}${SEP}${C_BRANCH}${GIT_INFO}${RESET}"
|
||||
out="${out}${SEP}${C_MODEL}[${MODEL}]${RESET}"
|
||||
out="${out}${SEP}${C_COST}\$${COST_FMT}${RESET}"
|
||||
out="${out}${SEP}${C_CTX}${CONTEXT_USED}%${RESET}"
|
||||
printf '%s\n' "$out"
|
||||
|
||||
@@ -74,8 +74,14 @@ in
|
||||
keybindings = {
|
||||
"kitty_mod+t" = "new_tab_with_cwd";
|
||||
"kitty_mod+enter" = "new_window_with_cwd";
|
||||
# --cwd=current: locally keeps the dir; over `kitten ssh` it clones the
|
||||
# SSH connection into the new split (the "mirroring").
|
||||
"kitty_mod+v" = "combine : goto_layout splits : launch --cwd=current --location=vsplit";
|
||||
"kitty_mod+s" = "combine : goto_layout splits : launch --cwd=current --location=hsplit";
|
||||
# Same splits, but a fresh LOCAL shell — no --cwd=current, so they never
|
||||
# clone an SSH session even when the active window is remote.
|
||||
"kitty_mod+shift+v" = "combine : goto_layout splits : launch --location=vsplit";
|
||||
"kitty_mod+shift+s" = "combine : goto_layout splits : launch --location=hsplit";
|
||||
"kitty_mod+r" = "set_tab_title";
|
||||
|
||||
"kitty_mod+u" = "previous_tab";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
_: {
|
||||
_:
|
||||
{
|
||||
programs.ssh = {
|
||||
enable = true;
|
||||
|
||||
@@ -28,13 +29,6 @@ _: {
|
||||
|
||||
"yolo" = {
|
||||
HostName = "10.7.10.2";
|
||||
|
||||
# Quiet the "channel N: open failed: connect failed: Connection
|
||||
# refused" noise (logged at INFO) when a forwarded port has nothing
|
||||
# listening yet. ExitOnForwardFailure stays off (default), so the
|
||||
# connection still succeeds over idle forwards.
|
||||
LogLevel = "ERROR";
|
||||
|
||||
RemoteForward = [
|
||||
{
|
||||
bind.port = 9222;
|
||||
@@ -42,8 +36,7 @@ _: {
|
||||
host.port = 9222;
|
||||
}
|
||||
];
|
||||
|
||||
# Auto-forward localhost:47100/47101 to the same ports on yolo.
|
||||
# localhost:417xx here -> yolo's listener on the same port.
|
||||
LocalForward = [
|
||||
{
|
||||
bind.port = 41700;
|
||||
@@ -56,6 +49,12 @@ _: {
|
||||
host.port = 41701;
|
||||
}
|
||||
];
|
||||
# When yolo's listener is down, forwarded connections fail with
|
||||
# "channel N: open failed: connect failed: Connection refused".
|
||||
# QUIET silences those (and bind-in-use warnings) without affecting
|
||||
# the session itself; ExitOnForwardFailure stays at its default (no),
|
||||
# so a missing listener never blocks the connection.
|
||||
LogLevel = "QUIET";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
initContent = ''
|
||||
[[ -f ~/.secrets.zsh ]] && source ~/.secrets.zsh
|
||||
# [[ -n "$KITTY_WINDOW_ID" ]] && alias ssh="kitten ssh"
|
||||
[[ -n "$KITTY_WINDOW_ID" ]] && alias ssh="kitten ssh"
|
||||
|
||||
export PATH="$HOME/.bin:$PATH"
|
||||
export PATH="''${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"
|
||||
|
||||
Reference in New Issue
Block a user