{"id":2236,"date":"2008-11-05T15:00:07","date_gmt":"2008-11-05T15:00:07","guid":{"rendered":"http:\/\/t.motd.kr\/articles\/2236\/opening-a-new-tab-in-an-existing-gnome-terminal-window"},"modified":"2022-12-28T01:45:30","modified_gmt":"2022-12-27T16:45:30","slug":"opening-a-new-tab-in-an-existing-gnome-terminal-window","status":"publish","type":"post","link":"https:\/\/vault.motd.kr\/wordpress\/posts\/2236\/opening-a-new-tab-in-an-existing-gnome-terminal-window\/","title":{"rendered":"Opening a new tab in an existing GNOME terminal window"},"content":{"rendered":"\n
Use RoxTerm<\/a> instead \u2013 GNOME<\/span> terminal<\/a> has great support for tabbed terminal sessions. You can simply open a new tab by pressing CTRL<\/span>+SHIFT+T and it\u2019s very convenient.<\/p>\n\n\n\n However, it seems like there\u2019s no straightforward way to ask So, I wrote a shell script that adds a new tab to an existing GNOME<\/span> terminal window when there is already a running instance. It also launches a new terminal window if necessary:<\/p>\n\n\n\n This script looks for an existing gnome-terminal window, sends CTRL<\/span>+SHIFT+T key event there, and raises the terminal window. Please note that xdotool<\/a> and wmctrl<\/a> are required to run the script. They should be available in most Linux distributions.<\/p>\n\n\n\n It\u2019s just a band-aid solution \u2013 I hope I can get rid of this script from my system when the next release of GNOME<\/span> terminal is out.<\/p>\n","protected":false},"excerpt":{"rendered":" Use RoxTerm instead \u2013 ‘roxterm –tab’ opens a new tab in an existing terminal window, with no hack described here. GNOME terminal has great support for tabbed terminal sessions. You can simply open a new tab by pressing CTRL+SHIFT+T and it\u2019s very convenient. However, it seems like there\u2019s no straightforward way to ask gnome-terminal command… Continue reading 'roxterm --tab'<\/code> opens a new tab in an existing terminal window, with no hack described here.<\/em><\/p>\n\n\n\n
gnome-terminal<\/code> command to reuse an existing window and add a new tab there. I tried various options like
--tab<\/code>, but they didn\u2019t work as I expected. I just want to keep only one terminal window in my desktop, but it looks like there\u2019s no command line option that does the job.<\/p>\n\n\n\n
#!\/bin\/bash\n# Path: \/usr\/local\/bin\/gnome-terminal\nif [ \"x$*\" != \"x\" ]; then\n \/usr\/bin\/gnome-terminal \"$@\"\nelse\n pgrep -u \"$USER\" gnome-terminal | grep -qv \"$\"\n if [ \"$?\" == \"0\" ]; then\n WID=`xdotool search --class \"gnome-terminal\" | head -1`\n xdotool windowfocus $WID\n xdotool key ctrl+shift+t\n wmctrl -i -a $WID\n else\n \/usr\/bin\/gnome-terminal\n fi\nfi<\/code><\/pre>\n\n\n\n