Created
January 11, 2026 06:54
-
-
Save ericallam/f47b4e63dd86d7555e28eef166bb6ede to your computer and use it in GitHub Desktop.
Claude Code Remote Session Helpers - Control Claude Code from your iPhone
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ============================================ | |
| # Claude Code Remote Session Helpers | |
| # ============================================ | |
| # Blog post: [YOUR_BLOG_URL] | |
| # | |
| # Prerequisites: | |
| # - Tailscale installed on Mac + iPhone | |
| # - Blink Shell on iPhone ($20) | |
| # - ntfy app on iPhone (free) | |
| # - jq installed (brew install jq) | |
| # | |
| # Setup: | |
| # 1. Create a unique ntfy topic at ntfy.sh | |
| # 2. Find your Blink URL key: Settings → Keyboard → X Callback URL Key | |
| # 3. Update NTFY_TOPIC and BLINK_KEY below | |
| # 4. Add this to your ~/.zshrc and run: source ~/.zshrc | |
| NTFY_TOPIC="your-topic-here" # Create at ntfy.sh, keep it secret | |
| BLINK_KEY="your-blink-key" # Found in Blink settings | |
| TMUX_PATH="/opt/homebrew/bin/tmux" # Adjust if your tmux is elsewhere | |
| claude-session() { | |
| local name="${1:-main}" | |
| # Create tmux session if it doesn't exist | |
| if ! $TMUX_PATH has-session -t "$name" 2>/dev/null; then | |
| $TMUX_PATH new-session -d -s "$name" | |
| echo "Created new session: $name" | |
| else | |
| echo "Attaching to existing session: $name" | |
| fi | |
| # Build Blink deep link | |
| local cmd="ssh mac -t '${TMUX_PATH} attach -t ${name}'" | |
| local encoded_cmd=$(printf '%s' "$cmd" | jq -sRr @uri) | |
| local blink_url="blinkshell://run?key=${BLINK_KEY}&cmd=${encoded_cmd}" | |
| # Send push notification | |
| curl -s \ | |
| -H "Title: Claude: $name" \ | |
| -H "Click: $blink_url" \ | |
| -H "Tags: computer" \ | |
| -d "Tap to open in Blink" \ | |
| "ntfy.sh/$NTFY_TOPIC" > /dev/null | |
| echo "Notification sent to iPhone" | |
| # Attach locally | |
| $TMUX_PATH attach -t "$name" | |
| } | |
| claude-list() { | |
| echo "Sessions:" | |
| $TMUX_PATH list-sessions 2>/dev/null || echo " (none)" | |
| } | |
| claude-kill() { | |
| local name="${1:-main}" | |
| if $TMUX_PATH kill-session -t "$name" 2>/dev/null; then | |
| echo "Killed session: $name" | |
| else | |
| echo "No session named: $name" | |
| fi | |
| } | |
| claude-notify() { | |
| local name="${1:-main}" | |
| if ! $TMUX_PATH has-session -t "$name" 2>/dev/null; then | |
| echo "No session named: $name" | |
| return 1 | |
| fi | |
| local cmd="ssh mac -t '${TMUX_PATH} attach -t ${name}'" | |
| local encoded_cmd=$(printf '%s' "$cmd" | jq -sRr @uri) | |
| local blink_url="blinkshell://run?key=${BLINK_KEY}&cmd=${encoded_cmd}" | |
| curl -s \ | |
| -H "Title: Claude: $name" \ | |
| -H "Click: $blink_url" \ | |
| -H "Tags: computer" \ | |
| -d "Tap to open in Blink" \ | |
| "ntfy.sh/$NTFY_TOPIC" > /dev/null | |
| echo "Notification sent for: $name" | |
| } | |
| claude-resume() { | |
| # List sessions and attach - for use when already SSH'd in via Blink | |
| local sessions=($($TMUX_PATH list-sessions -F "#{session_name}" 2>/dev/null)) | |
| if [ ${#sessions[@]} -eq 0 ]; then | |
| echo "No active sessions" | |
| return 1 | |
| fi | |
| if [ ${#sessions[@]} -eq 1 ]; then | |
| # Only one session, attach directly | |
| echo "Attaching to: ${sessions[1]}" | |
| $TMUX_PATH attach -t "${sessions[1]}" | |
| elif [ -n "$1" ]; then | |
| # Session name provided | |
| $TMUX_PATH attach -t "$1" | |
| else | |
| # Multiple sessions, show picker | |
| echo "Sessions:" | |
| local i=1 | |
| for s in "${sessions[@]}"; do | |
| echo " $i) $s" | |
| ((i++)) | |
| done | |
| echo "" | |
| read "choice?Enter number or name: " | |
| if [[ "$choice" =~ ^[0-9]+$ ]] && [ "$choice" -ge 1 ] && [ "$choice" -le ${#sessions[@]} ]; then | |
| $TMUX_PATH attach -t "${sessions[$choice]}" | |
| else | |
| $TMUX_PATH attach -t "$choice" | |
| fi | |
| fi | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment