It does not seem that there is any functionality in
gnome-terminal to add a new tab to an existing window from the command-line. But there are a few options to accomplish what you want.
Per Command Profiles
Create a new
gnome-terminal profile for each host you will SSH into. If you only have a few hosts that you regularly connect to, this might be the simplest. Each profile can have a different title, foreground color, background color, custom command and other settings defined. Then you can use
File -> Open Tab to open a new tab with the selected profile.
Create a new
gnome-terminal profile that will be used to open a new window each time you want to connect to a different SSH host (based on this AskUbuntu answer that Stefano pointed out). This would work good if you connect to many different hosts frequently. This will not allow you to distinguish between different
gnome-terminal windows where you are connected to different hosts solely on the background/foreground colors, but you will have a different title per window.
- Create a new
gnome-terminal profile (
File -> New Profile) based on the
Default profile and call it "RemoteHost" (note, no spaces in "RemoteHost" to make commands easier).
- Under the
Title and Command tab, change:
Initial title: to "Remote Host"
When terminal commands set their own titles: to
Replace initial title
- Under the
Colors tab, change:
Use colors from system theme
Build-in schemes: to
Text color: and
Background color: to colors of your choosing. Keep in mind that some commands (like
ls) use colors for their output and you don't want to pick colors that will make it difficult to read the output.
- Click on the
Close button to save your new profile.
- Now you can open a new
gnome-terminal window for each remote SSH host using the command
gnome-terminal --window-with-profile=RemoteHost -t "Some Remote SSH Host" -x ssh user@somehost. The
-t option sets the
gnome-terminal window title and the
-x option executes the rest of the command line in the terminal. You could even make an
alias to shorten total keystrokes.
I found this blog entry with the following script that uses the
wmctrl commands (they weren't installed by default on Ubuntu, so you might need to install them first) to use the
gnome-terminal Ctrl + Shift + t keyboard shortcut to open a new tab in the current
gnome-terminal window. It could be modified to open a new tab with a specific profile and execute some command for you.
# Path: /usr/local/bin/gnome-terminal
if [ "x$*" != "x" ]; then
pgrep -u "$USER" gnome-terminal | grep -qv "$$"
if [ "$?" == "0" ]; then
WID=`xdotool search --class "gnome-terminal" | head -1`
xdotool windowfocus $WID
xdotool key ctrl+shift+t
wmctrl -i -a $WID
You could get creative and try some other things.
This SuperUser answer basically uses a bit of "script-fu" acrobats to create a temporary
gnome-terminal profile that is used to open a new window. It may be modified for your use.
You could probably use this StackOverflow Q&A and more "script-fu" acrobats to dynamically change the
gnome-terminal title whenever you SSH to a remote host. It would not be as prominent as background/foreground color changes, but it would be better than a standard
Terminal title all the time.