Skip to content

Instantly share code, notes, and snippets.

@jordangarcia
Created January 23, 2026 19:43
Show Gist options
  • Select an option

  • Save jordangarcia/97d64d4f6790b8d7e2b8305768f3c11a to your computer and use it in GitHub Desktop.

Select an option

Save jordangarcia/97d64d4f6790b8d7e2b8305768f3c11a to your computer and use it in GitHub Desktop.
#!/bin/bash
# Show processes spawned from wezterm, with detailed view of gamma dev stack
WEZTERM_PID=$(ps -eo pid,command | grep "[w]ezterm-gui" | awk '{print $1}')
if [[ -z "$WEZTERM_PID" ]]; then
echo "wezterm not running"
exit 1
fi
echo "=== WezTerm Shells (PID $WEZTERM_PID) ==="
echo ""
# Get direct child shells
SHELLS=$(pgrep -P "$WEZTERM_PID")
for shell_pid in $SHELLS; do
# Get first meaningful child process name
child_info=$(ps -p "$shell_pid" -o pid=,command= 2>/dev/null)
first_child=$(pgrep -P "$shell_pid" | head -1)
if [[ -n "$first_child" ]]; then
child_cmd=$(ps -p "$first_child" -o command= 2>/dev/null)
# Check if this is the gamma dev stack
if echo "$child_cmd" | grep -q "dev-cli\|process-compose\|gamma.*yarn"; then
echo "[$shell_pid] gamma dev stack"
GAMMA_SHELL=$shell_pid
elif echo "$child_cmd" | grep -q "nvim"; then
echo "[$shell_pid] nvim"
elif echo "$child_cmd" | grep -q "claude"; then
echo "[$shell_pid] claude"
else
echo "[$shell_pid] $child_cmd"
fi
else
echo "[$shell_pid] idle zsh"
fi
done
# If we found gamma dev stack, show detailed child processes
if [[ -n "$GAMMA_SHELL" ]]; then
echo ""
echo "=== Gamma Dev Stack Processes ==="
echo ""
printf "%-8s %-50s %10s\n" "PID" "NAME" "MEM (MB)"
printf "%-8s %-50s %10s\n" "--------" "--------------------------------------------------" "----------"
# Recursively print process tree with indentation
print_tree() {
local pid=$1
local depth=$2
local indent=""
for ((i=0; i<depth; i++)); do
indent=" $indent"
done
# Get process info
info=$(ps -p "$pid" -o rss=,command= 2>/dev/null)
if [[ -n "$info" ]]; then
rss_kb=$(echo "$info" | awk '{print $1}')
cmd=$(echo "$info" | awk '{$1=""; print $0}' | sed 's/^ //')
name=$(echo "$cmd" | sed 's|.*/||' | cut -c1-$((50 - ${#indent})))
mem_mb=$(awk "BEGIN {printf \"%.1f\", $rss_kb / 1024}")
printf "%-8s %-50s %10s\n" "$pid" "${indent}${name}" "$mem_mb"
fi
# Recurse into children
for child in $(pgrep -P "$pid" 2>/dev/null); do
print_tree "$child" $((depth + 1))
done
}
# Start from gamma shell's first child
for child in $(pgrep -P "$GAMMA_SHELL" 2>/dev/null); do
print_tree "$child" 0
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment