When a terminal is running and I launch another, is there any way to open a new tab in the same window instead of open a new window?

  • 2
    I don't fully understand your question: How will you lunch another terminal? If you are in terminal, just push Ctrl+Shift+T, and a new tab will open.
    – bigbang
    Commented Feb 9, 2016 at 6:44
  • 1
    When the terminal window is not on focus and I push Cmd + T to launch a new one I would like to open a new tab and not open a new window.
    – jacosro
    Commented Feb 9, 2016 at 11:14
  • Are you in Freya or Loki? That may count, on whether the window is focused or not by a shortcut.
    – user170
    Commented Oct 10, 2016 at 20:20

5 Answers 5


pantheon-terminal actually has an undocumented command line option -w with which you can specify a working directory for the new terminal.
This option also handily checks for already existing pantheon-terminal windows and opens a new tab if there is one, or a new window if there isn't.

I've written a tiny script that simply uses that option and then focuses the terminal with wmctrl:


pantheon-terminal -w ''
# A small sleep might be useful if the terminal doesn't open fast enough for wmctrl to focus it
#sleep 0.05
wmctrl -ia $(wmctrl -lx | sed -n 's/^\(0x[0-9a-f]\{8\}\)\s\{1,2\}[0-9-]\+ pantheon-terminal\.Pantheon-terminal .*$/\1/p' | tail -n1)

The script depends on the wmctrl package.

It will open the new tab in the last opened terminal window. If you'd rather like it opened in the first opened window, check the history of my answer for an older version of the script with that behaviour.

I saved the script to /opt/open-terminal.sh and made it executable with
chmod +x /opt/open-terminal.sh

I've mapped the script to the <Super>+T key combination so that I can easily open a new terminal whenever and wherever:

                         global shortcut set in switchboard

If you want that behaviour whenever you click on the Terminal shortcut, you could probably simply change the Exec parameter to the script.

This command wil make a copy of the pantheon-terminal shortcut for your user and set it to execute the script:

sed '/^\[Desktop Entry\]$/,/^Exec=pantheon-terminal$/{s#Exec=pantheon-terminal$#Exec=/opt/open-terminal.sh#}' /usr/share/applications/pantheon-terminal.desktop > ~/.local/share/applications/pantheon-terminal.desktop

elementaryOS Loki (v0.4):

As pointer out by @cipricus in the comments, it seems that with pantheon-terminal v4.0+ (Loki and above), they changed the behaviour of the -w option to also automatically focus the temrinal window.
So if you are on Loki, you only have to add:

pantheon-terminal -w ''

as the command in the custom keyboard shortcuts and the desktop shortcut.

Here's the command to create a copy of the desktop shortcut with only the pantehon-terminal -w command:

sed '/^\[Desktop Entry\]$/,/^Exec=pantheon-terminal$/{s#Exec=pantheon-terminal$#Exec=pantheon-terminal -w ""#}' /usr/share/applications/pantheon-terminal.desktop > ~/.local/share/applications/pantheon-terminal.desktop
  • 1
    Why is the script needed when the command panthon-terminal -w '' can be used with a custom shortcut, be it a re-assigned Super-T or some other shortcut, as well as with a launcher/dock icon?
    – user170
    Commented Oct 10, 2016 at 19:19
  • 1
    Yes, I actually mapped Super-Shift-T to the command panthon-terminal -w '' so I can open a new terminal (without Shift) or a new tab (with Shift). It also gets the focus (elementary OS 0.4 Loki) so there is no need of the wrapper script.
    – lemonslice
    Commented Oct 10, 2016 at 19:37
  • @cipricus Only pantheon-terminal -w '' won't focus the terminal window, at least not for me. wmctrl -a switches to the desktop the window is on and brings it to the front.
    – halfbit
    Commented Oct 10, 2016 at 19:45
  • For me the command pantheon-terminal -w WHATEVER will focus the terminal window. Could be it because, as suggested in a comment by lemonslice, this is only the case in Loki? Are you in Freya? - I have added a complementary answer that you should feel free to copy/paste or otherwise integrate into yours and then I may delete mine. If you do not have enough reputation score, ask me to do it instead.
    – user170
    Commented Oct 10, 2016 at 20:01
  • I'm using pantheon on top of debian. The repository here seems to be at Freya, pantheon-terminal has version It's quite possible they added the focusing in 0.4, yea.
    – halfbit
    Commented Oct 10, 2016 at 20:13

Keyboard Shortcut is


More elementary tutorials found at WebCheerz

  • That isn't exactly what the questioner wanted. The questioner wanted opening terminal via Cmd+T, dock or application launcher to result in a new tab in an existing window instead of a new window. Commented Mar 2, 2016 at 14:25
  • The problem is with that shortcut not being a global shortcut: one that works also when the terminal is not in focus.
    – user170
    Commented Oct 10, 2016 at 18:56
  • as indicated in the other answer, the needed command is pantheon-terminal -w ''. That can be used with a shortcut or with a launcher. (I don't see the need for the script.)
    – user170
    Commented Oct 10, 2016 at 19:18

The default terminal in Elementary OS offers the possibility to open a new tab. On the left side of the terminal you'll find a plus which opens a new tab in the same window.

Open new tab


This is a complement (tested in Loki) to the other answer that shows that a good command is

pantheon-terminal -w ''

The command pantheon-terminal -w %u is present in the file usr/share/applications/open-pantheon-terminal-here.desktop. The `''´ part is needed in that some character has to be used there, but anything can go, like a dot, or even a poetry line

pantheon-terminal -w 'My name is Ozymandias, king of kings: Look on my works, ye Mighty, and despair!'

This command can be used to replace the default one in usr/share/applications/org.pantheon.terminal.desktop (the default desktop file of the terminal), or in a new desktop file to be kept in dock, etc.; also, the default Super-T can be reassigned to this command, or a new shortcut can be created for this command in Keyboard > Custom > Add.

enter image description here


This will set the default new tab's path to that of the previous tab

gsettings set org.pantheon.terminal.settings follow-last-tab true

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.