Skip to content

Instantly share code, notes, and snippets.

@J-Swift
Created April 14, 2026 13:30
Show Gist options
  • Select an option

  • Save J-Swift/67a6d91251a15fee8ddba7ce5b183a45 to your computer and use it in GitHub Desktop.

Select an option

Save J-Swift/67a6d91251a15fee8ddba7ce5b183a45 to your computer and use it in GitHub Desktop.
Show all open claude code sessions with CWD
anyclaude ()
{
ps -eo user,pid,tty,start,command | grep --color=auto -i claude | grep --color=auto -v grep | grep --color=auto -v Claude.app | grep --color=auto -v Zed | while read -r line; do
pid=$(echo "$line" | awk '{print $2}');
cwd=$(lsof -d cwd -a -p "$pid" -Fn 2> /dev/null | awk '/^n/{print substr($0,2)}');
printf '%s [%s]\n' "$line" "${cwd:-?}";
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment