Finding the terminal your script is running in - Programming On Unix

Users browsing this thread: 1 Guest(s)
movq
Long time nixers
By the way, we totally missed the original intention of the person in the original german thread (the german OP only posted this after venam's last reply in 2016 ... classic X/Y problem):

They have an application that runs in a terminal. This application wants to start new terminals. So, naturally, it needs to know which terminal (XTerm, GNOME terminal, ...) that is. Hence the idea of trying to find the terminal that you're running in.

This finally gives us a much better definition of "the terminal". :) It's an X11/Wayland terminal emulator. Complications like tmux can be ignored entirely.

So, yeah, essentially what z3bra said.

But there's an additional constraint: The original OP wanted to set a window title, e.g. `sakura -t 'my fancy window title' -x 'sleep 20'`. Of course, pretty much every terminal emulator has its own set of command line arguments, so you have to know about all of them and thus you have to test for specific processes (`/proc/$pid/exe`) anyway.

Kind of a weird way to do things. If there was a standard variable like $EDITOR, the problem wouldn't exist in the first place.


Messages In This Thread
RE: Finding the terminal your script is running in - by movq - 13-08-2020, 06:45 AM