Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Then from any terminal, just 'kill PID#' (where PID# is the Process Identification number of the process you wanted to kill) EDIT: If you're trying to kill the xterm window that's using 'pts/14', then look for the shell running it ( -sh, -bash, -ksh ) and kill that.
thanks, not exactly what i need. i need to find/locate the terminal window which represents pts/14, for e.g. listing all backgroundjobs, running in this bash session.
is there a command which brings a given pts to foreground and switches to the corresponding workspace?
is there a command which brings a given pts to foreground and switches to the corresponding workspace?
I'm not aware of any such command, though it would be specific to either the Window Manager you're using (GNOME, KDE, FluxBox, etc) or the Terminal Emulator (Konsole, Gnome Terminal, xterm, etc).
Never seen a command that did anything like that. Closest would be just Alt-Tab'ing around till you found a Terminal with 'pts/##' in the title.
How to Get the Terminal Number in an Xterm Window's Title
You could add the following to your shell's start-up file (.kshrc, .bashrc, .bash_profile, .profile, etc).
This is not just 'drop-in' code, only an example of how you would get the 'pts/#' in the title of a Terminal.
(Note that my .kshrc is about 700 lines long, and various things get collected/defined, then wind up in my Title)
Code:
TTY=$( /usr/bin/tty ) # Stores the full name of the TTY
TTY_DEV=${TTY##*/dev/} # Cuts-out the "/dev/" prefix, which leaves "pts/0", "console", or "ttyUSB0"
TITLE="${TTY_DEV} " # Here we could put other env vars that we want to display in a terminal's title....
print "\033]0;${TITLE}\007\c" # Actually changes the Terminal's title.
you need to write a script to do that.
first locate the shell opened that terminal and than find parent process (that is the terminal emulator hopefully) and then you can send a signal to it.
remember, you cannot bring a pts to the foreground but a terminal window.
if i open a terminal window (gnome-terminal) which has let's say PID 12000 and runs in let's say pts5, and then open a second one, this runs in pts6. both share the same PPID (12000). there is only one gnome-terminal process with two childs; the two instances of bash, running in different pts. so i cannot use the PID of gnome-terminal to focus a special terminal window.
... wmctrl: BINGO
AFAIK wmctrl cannot focus a window directly by either PID odr pts number, but:
setting PS1 to "\[\e]0;[\u@\h:\l \W]\\$ \a\][\u@\h:\l \W]\\$" puts the pts number of my terminalwindow in the windowtitle (...\l...), and with wmctrl -a :6 i can focus a window, which has the substring :6 (the pts number) in its title.
issue solved for me, thank you all for your replies
... if i open a terminal window (gnome-terminal) which has let's say PID 12000 and runs in let's say pts5, and then open a second one, this runs in pts6 ...
the gnome-terminal process itself is not connected to pts5, it is the bash process, which will be automatically started by gnome-terminal, which runs in pts5.
all other statements are correct, and work for me. thanks.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.