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.

4
  • 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. Commented Dec 5, 2019 at 20:21
  • related: unix.stackexchange.com/questions/492302/… Commented Dec 5, 2019 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. Commented Dec 5, 2019 at 20:27
  • Hmm, maybe I'll try to guess it from that, and if that fails, fallback onto a hardcoded solution. Commented Dec 6, 2019 at 3:58

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.