1

I have to open a tab in gnome-terminal with 'emacs -nw' (application) in the newly opened tab.

$who
user     :0           2016-08-24 10:39 (:0)
user     pts/0        2016-08-24 14:03 (:0)

I wrote a script after runing 'who' command.

#!/bin/bash

xdotool key ctrl+shift+t
/usr/bin/emacs -nw $1 > /dev/pts/1

While running this script its opening the new tab. But emacs is opening in same gnome-terminal.

Any one can explain me why its happening like this? and can explain how to open the emacs -nw (application) in new tab without disturbing current gnome-terminal.

  • http://stackoverflow.com/q/1188959/245173 – jpkotta Aug 24 '16 at 17:58
  • This link have an answer about how to open a gnome-terminal. But my question is to open a emacs or some other application instead of running the command like _ls_ in new tab without disturbing the current terminal. I want to work on current terminal without disturbance. – Lakshmanan G Aug 25 '16 at 05:19
  • But the answer is the same. Here's what your script does: it artificially types `C-S-t`, and since you're running the script from the terminal, the terminal has focus and thus gets the key presses. It makes a new tab as if you had typed `C-S-t`. Then it runs a command (emacs) *in the original tab*, because that's where the script is running. That command's stdout is also redirected to a pseudoterm, which is almost certainly not what you want. I'm guessing you wanted to echo the actual command, not its output, to the pty corresponding to the new terminal. – jpkotta Aug 25 '16 at 17:00
  • Options: 1) figure out how to get gnome-terminal to start a new tab and run a command in it; it will probably look something like `gnome-terminal --tab -e emacs ...`. I'm not familiar with gnome-terminal; this may or may not be supported. 2) artificially type your command in like you do with the `C-S-t`. This is what the question I linked to shows. 3) Somehow figure out which pty corresponds to the new tab (I'm not sure how easy that will be), and then echo the command to it. – jpkotta Aug 25 '16 at 17:06
  • After looking into more, I'm guessing option 3 is not going to work. You definitely can't just echo a command to the pty, you need to somehow give it to the shell (the term doesn't actually run anything, it just displays things), or force emacs to attach to your desired pty (again, not sure if this is possible). – jpkotta Aug 25 '16 at 17:32
  • Thank you for your response. I am looking for the terminal to run emacs. – Lakshmanan G Aug 29 '16 at 05:04

0 Answers0