0

I want to run a script in a new terminal window. I found several solutions such as this. However, they all provide terminal specific solutions. So konsole ./myscript.sh works if I'm using konsole, but not if I'm using gnome-terminal or some other terminal program.

Is there a way to open a new terminal that is of the same type as the current one? Or equivalently, a way to locate the executable for the currently running terminal? Or am I misunderstanding something and this doesn't make sense in general, and I should just hardcode a few specific options.

I primarily use arch, debian, and ubuntu, so if there is a solution that works on just those three that would be fine, albeit suboptimal.

  • I don't think there's any general solution to that. A quick and dirty solution is to guess the name of the terminal from the parent proces: case $(cat /proc/$PPID/comm) in gnome-*) ... ;; konsole*) ...;; esac (you cannot use the command name directly with gnome, since gnome-terminal does not start itself a shell process, but asks gnome-terminal-server to do it for it. –  Dec 05 '19 at 20:21
  • related: https://unix.stackexchange.com/questions/492302/how-can-we-find-out-the-pseudoterminal-master-and-slave-from-each-other –  Dec 05 '19 at 20:25
  • There's also the $WINDOWID environment variable (which could allow you to get the name of the terminal command via the _NET_WM_PID or WM_COMMAND properties), but it's not set by gnome-terminal. –  Dec 05 '19 at 20:27
  • Hmm, maybe I'll try to guess it from that, and if that fails, fallback onto a hardcoded solution. – Conor Marco Dec 06 '19 at 03:58

0 Answers0