diff --git a/home-configs/claude/hooks/switch-account-hook.sh b/home-configs/claude/hooks/switch-account-hook.sh index a43e2c1..568b344 100755 --- a/home-configs/claude/hooks/switch-account-hook.sh +++ b/home-configs/claude/hooks/switch-account-hook.sh @@ -40,9 +40,22 @@ echo "$next" > "$CURRENT_FILE" echo "Аккаунт: ${current:-?} -> ${next} (всего: ${#accounts[@]})" >&2 -# Посылаем SIGWINCH процессу claude с задержкой в фоне (после отрисовки блокировки) +# Тригерим resize через TIOCSWINSZ на TTY claude (надёжнее чем kill -WINCH) sh_pid=$PPID claude_pid=$(awk '/PPid/{print $2}' /proc/$sh_pid/status 2>/dev/null) -[ -n "$claude_pid" ] && ( sleep 0.3 && kill -WINCH "$claude_pid" 2>/dev/null ) & +if [ -n "$claude_pid" ]; then + tty_dev=$(ps -o tty= -p "$claude_pid" 2>/dev/null | tr -d ' ') + if [ -n "$tty_dev" ] && [ "$tty_dev" != "?" ]; then + ( sleep 0.3 && python3 -c " +import fcntl, termios, struct, sys +try: + fd = open('/dev/$tty_dev', 'rb+', buffering=0) + ws = fcntl.ioctl(fd, termios.TIOCGWINSZ, bytes(8)) + fcntl.ioctl(fd, termios.TIOCSWINSZ, ws) + fd.close() +except: pass +" ) & + fi +fi exit 2