nelhage / reptyr

Reparent a running program to a new terminal
MIT License
5.77k stars 216 forks source link

how can I get the ouput of reptyr -l into tmux #87

Closed amosbird closed 7 years ago

amosbird commented 7 years ago

I'm writing a script using tmux and gdb to automatically generate a productive debugger. Currently I use sleep infinity to set up an inferior tty. I'd like to switched to reptyr -l. However, i cannot get the output of reptyr -l in order to make the whole setting up process automatic.

The script looks like this ,

#!/usr/bin/env bash

tmux neww -n Debug
tmux splitw -h -p 50
tmux select-pane -t 1
tty1=$(tmux display -p "#{pane_tty}")
tmux splitw -v -p 40
tty3=$(tmux display -p "#{pane_tty}")
tmux select-pane -t 1
tmux splitw -v -p 40
tty2=$(tmux display -p "#{pane_tty}")
# tmux send-keys "reptyr -l" C-m
tmux send-keys "sleep infinity" C-m
tmux select-pane -t 4
tmux send-keys "cgdb -- $1 -tty $tty2 -ex \"dashboard -output $tty1\" -ex \"dashboard expression -output $tty3\"" C-m
nelhage commented 7 years ago

If you run reptyr -l with a command line, it will execute that command with the REPTYR_PTY environment variable set. So you could do something like

reptyr -l sh -c 'echo $REPTYR_PTY > /tmp/reptyr-pty'

and then read the pty out of that tmpfile.