Last active
July 28, 2026 16:26
-
-
Save istarkov/d747c6f0ee73042ba3e47deb6ad6594b to your computer and use it in GitHub Desktop.
Show `remote-control` claude code sessions locally and allow to select
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
| crs() { | |
| local f cwd title mtime | |
| local c_time=$'\e[38;5;110m' c_dir=$'\e[38;5;180m' c_off=$'\e[0m' | |
| for f in "$HOME"/.claude/projects/*/*.jsonl(N.m-7); do | |
| grep -q '"entrypoint":"sdk-cli"' "$f" && grep -q '"origin":{"kind":"human"}' "$f" || continue | |
| cwd=$(grep -m1 -o '"cwd":"[^"]*"' "$f" | sed 's/"cwd":"//;s/"//') | |
| title=$(grep -o '"customTitle":"[^"]*"' "$f" | tail -1 | sed 's/"customTitle":"//;s/"//') | |
| [[ -z "$title" ]] && title=$(grep -m1 '"operation":"enqueue"' "$f" | sed 's/.*"content":"//;s/".*//' | cut -c1-200) | |
| mtime=$(stat -c '%y' "$f" | cut -d. -f1) | |
| printf 'cd %s && claude --resume %s # %s%s%s [%s%s%s] %s\n' \ | |
| "$cwd" "$(basename "$f" .jsonl)" \ | |
| "$c_time" "$mtime" "$c_off" "$c_dir" "${cwd:t}" "$c_off" "$title" | |
| done | sort -t'#' -k2r | |
| } | |
| # List ALL claude code sessions from the last week (every project) | |
| _claude_sessions_all() { | |
| local f cwd title mtime | |
| local c_time=$'\e[38;5;110m' c_dir=$'\e[38;5;180m' c_off=$'\e[0m' | |
| for f in "$HOME"/.claude/projects/*/*.jsonl(N.m-7); do | |
| cwd=$(grep -m1 -o '"cwd":"[^"]*"' "$f" | sed 's/"cwd":"//;s/"//') | |
| [[ -z "$cwd" ]] && continue | |
| title=$(grep -o '"customTitle":"[^"]*"' "$f" | tail -1 | sed 's/"customTitle":"//;s/"//') | |
| [[ -z "$title" ]] && title=$(grep -m1 -o '"role":"user","content":"[^<"][^"]\{1,200\}' "$f" | sed 's/.*"content":"//') | |
| [[ -z "$title" ]] && title="(no prompt)" | |
| mtime=$(stat -c '%y' "$f" | cut -d. -f1) | |
| printf 'cd %s && claude --resume %s # %s%s%s [%s%s%s] %s\n' \ | |
| "$cwd" "$(basename "$f" .jsonl)" \ | |
| "$c_time" "$mtime" "$c_off" "$c_dir" "${cwd:t}" "$c_off" "$title" | |
| done | sort -t'#' -k2r | |
| } | |
| # fzf-pick a session produced by "$2..." (a command), then cd + resume it. | |
| # Titles: "\n" escapes become real newlines, max 5 lines per entry. | |
| _claude_sessions_pick() { | |
| local header=$1 line | |
| shift | |
| line=$("$@" \ | |
| | awk '{n=split($0,a,/\\n/); s=a[1]; for(i=2;i<=n&&i<=5;i++) s=s "\n" a[i]; printf "%s%c", s, 0}' \ | |
| | fzf --read0 --ansi --highlight-line --gap=1 --header="$header" \ | |
| --delimiter='# ' --with-nth=2 \ | |
| --preview 'echo {1}' --preview-window=down,3,wrap) || return | |
| eval "${line%% #*}" | |
| } | |
| # Show ALL claude code sessions from the last week (every project) and select | |
| cca() { | |
| _claude_sessions_pick 'Claude sessions (last week)' _claude_sessions_all | |
| } | |
| # Show `remote-control` claude code sessions locally and allow to select | |
| ccr() { | |
| _claude_sessions_pick 'Remote Claude sessions' crs | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ccr — resume remote sessions
Remote Control lets you run Claude Code
on your machine and drive it from your phone or claude.ai/code:
claude remote-control— waits in the terminal, you create sessions from the phoneclaude --rc— normal terminal session that your phone can also seeThe problem: sessions you start from the phone don't show up in
claude --resume.The transcripts are on your disk, the picker just hides them.
ccrfinds them, shows an fzf list, Enter — you're in the right folder with the session resumed.cca — resume any session, anywhere
claude --resumeonly shows sessions from the folder you run it in.ccashows last week's sessions from all projects in one fzf list — search by time,folder or prompt, Enter — same thing, right folder, session resumed.
Screen.Recording.2026-07-28.at.18.44.23.mov