I am currently writing a script to open several tabs in gnome-terminal, and set their titles. I can open multiple tabs, but I need to change focus to those tabs (programatically) in order to set their titles from my script.
I use zsh and bash interchangeably, so any bash commands should work fine. I am starting to get familiar with xdotool
and wmctrl
, but unsure of a combo of commands to switch focus to an open tab.
What commands can I use to "switch to next open tab" or "switch to tab N" from a gnome-terminal CLI?
I solved this with xdotool
On one line, first, open a new tab with the
key
command. The default behavior is to switch focus to this tab. Then, use thetype
command to run a function, script, or other program in the new tab. Last, use thekey
command to "press enter." Repeat for N-many tabs!