Mike McClain (HE12025-08-11):
> I've defined to9 () { echo "$1" > /dev/tty9 } to be used from an xterm.
> I'd like to have a similar function toX() to be used on a virtual
> terminal that would print some text on the xterm running only bash
> but that xterm varies which /dev/pts/? it's running on and so far
> I've not found a way without manually going into X and entering 'tty'
> on that xterm to find out which /dev/pts to direct an echo to.
> If I can learn how to determine which /dev/pts/? is running only bash
> and not mc or something else then I can write toX() to just work.So this was a XY problem. Do not try to guess which terminal is running “only bash”, have the terminal you want run something before bash or when bash starts to prepare what you want. Before bash: xterm -e 'something ; $SHELL' When bash starts: vim .bashrc As for the best way to prepare what you want… You first need to determine the tty of the script. With zsh it would be easy, that is $TTY; bash does not have that convenient feature, so you will need TTY=$(tty). Then you need to export that information. There are many ways. An old convention that group-writable ttys are for receiving message. So: “chmod g+w $TTY”. Or you can use a symlink at a specific place: “ln -s $TTY $XDG_RUNTIME_DIR/my_message_tty”. There are other possibilities. Regards, -- Nicolas George

