I have the habit of opening a terminal using the "Open terminal here" command in folders. This causes a few terminals to remain open while I don't really use them anymore, or I get confused which terminal was serving which purpose.

I know I can label terminal tabs and such, but can I force a new terminal that is being openened, to become a new tab in a terminal screen (if there is one open already?) This way I always have them tabbed in a single terminal.

EDIT Okay, so it's been a while and my linux mojo has improved a lot. So the current solution to this situation for me has been using tmux. It's a little more advanced than regular terminals and tabs but once I got the hang of it (about an hour of trying) I'm very pleased with the way of going about things.

First of all, I made sure that whenever I opened a terminal using ctrl-alt-t, it would open tmux by default. This can be achieved by adding the following line in your .bashrc file after all the aliases:

[[ $TERM != "screen" ]] && exec 'tmux

Now everytime you spawn a terminal using ctrl-alt-t you will be presented with a tmux.

To make sure you only have one terminal open at the same time I did the following:

First of all, you can reattach a session in tmux by running tmux attach -d. This will disconnect all other clients connected to this session. This works fine if you are the only person using the sessions.

But, if you don't have a session running it will say it did not find any sessions. Ergo, you need something like if(nosession) { tmux } else { tmux attach -d }. To do this create of append to your ~/.tmux.conf file the following line:

#if run as "tmux attach", create a session if one does not already exist
new-session -n $HOST

(Thanks to this post)

In my .bashrc file, I changed the line added previously to the following:

[[ $TERM != "screen" ]] && exec 'tmux attach -d'

What this does is detach all other clients from the tmux session. When you do this, all other terminals close. They close because this line also makes sure that when you open a terminal (ctrl-alt-t), it immediatly starts a tmux session.

Ergo, attach -d kills the other sessions. So this is the closest fix I could get and I'm rather happy with it! :)

The only thing I would still like is that when I press ctrl-alt-t it opens up my current session and also creates a new window. I haven't figured that out yet so feel free to help!

  • Press ctr+shift+t to open tab in terminal. Apr 2, 2014 at 17:14
  • Yes I'm aware of that. However, as I said, I frequently open tabs from within a directory using the plugin "Open terminal here" (this is default in Xubuntu for example). These open a new window. I would like these to be opened as a new tab in the already existing terminal window. Apr 2, 2014 at 20:33

1 Answer 1


Unfortunately opening new tabs in the existing gnome-terminal session has been a wanted feature for a several years now - see here.

It would be possible to hack something together, though. For instance this answer provides a hack to open a new tab in the current window of gnome-terminal.

  • Excellent. +1 for the link to the bug report. I can only encourage everybody to click the "this affects me too" link on top to draw some attention to this. Also +1 for the hack. Great answer! May 1, 2014 at 21:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .