Commit b7cced941b8e
Changed files (2)
dots
.config
claude
tools
shpool-ssh-wrapper
dots/.config/claude/settings.json
@@ -61,6 +61,7 @@
]
},
"trustedWorkspaces": [
- "/home/vincent"
+ "/home/vincent",
+ "/home/vincent/src/home"
]
}
tools/shpool-ssh-wrapper/default.nix
@@ -2,10 +2,17 @@
let
# Helper script to start Claude Code with Vertex AI environment
+ # Takes optional directory argument: claude-vertex [directory]
claude-vertex = pkgs.writeShellScript "claude-vertex" ''
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=us-east5
export ANTHROPIC_VERTEX_PROJECT_ID=itpc-gcp-pnd-pe-eng-claude
+
+ # Change to specified directory if provided
+ if [ -n "''${1:-}" ]; then
+ cd "$1"
+ fi
+
# Use full path since PATH isn't set in non-login shells
exec /etc/profiles/per-user/vincent/bin/claude
'';
@@ -14,17 +21,26 @@ in
pkgs.writeScriptBin "shpool-ssh-wrapper" ''
#!${pkgs.bash}/bin/bash
# Shpool SSH wrapper - automatically runs commands for specific session patterns
+ # Supports syntax: session-name=directory (e.g., "claude/home=src/home")
set -euo pipefail
- # Get the session name from SSH original command (e.g., "aomi.home/claude/session1" -> "claude/session1")
- SESSION_NAME="''${1}"
+ # Parse session spec: "claude/home=src/home" -> session="claude/home", dir="src/home"
+ SESSION_SPEC="''${1}"
+ if [[ "$SESSION_SPEC" =~ ^([^=]+)=(.+)$ ]]; then
+ SESSION_NAME="''${BASH_REMATCH[1]}"
+ WORK_DIR="''${BASH_REMATCH[2]}"
+ else
+ SESSION_NAME="$SESSION_SPEC"
+ WORK_DIR=""
+ fi
# Function to run shpool with a specific command
run_with_command() {
local session="$1"
local cmd="$2"
- exec ${pkgs.shpool}/bin/shpool attach -f -c "$cmd" "$session"
+ shift 2
+ exec ${pkgs.shpool}/bin/shpool attach -f -c "$cmd $*" "$session"
}
# Check session name patterns and run appropriate commands
@@ -32,7 +48,11 @@ pkgs.writeScriptBin "shpool-ssh-wrapper" ''
claude/*)
# Claude Code session - run with Vertex AI environment
# Use helper script since shpool -c expects a binary, not a shell command
- run_with_command "$SESSION_NAME" "${claude-vertex}"
+ if [ -n "$WORK_DIR" ]; then
+ run_with_command "$SESSION_NAME" "${claude-vertex}" "$WORK_DIR"
+ else
+ run_with_command "$SESSION_NAME" "${claude-vertex}"
+ fi
;;
*)
# Default: just attach to session with default shell