105

Is it possible to open a new tab in the current terminal with some commands?

110

If you just want to open a new tab

To open a new tab in the current opened terminal you can press SHIFT+CTRL+T. Alternatively, use the top level menu, which shows the keyboard shortcut (see screenshot below)

If you want to do it from the command line

Install xdotool - a program that lets you simulate keyboard input (among other things).

sudo apt-get install xdotool

then type in the terminal:

xdotool key ctrl+shift+t

That will simulate pressing the key combination, and open the new tab in the terminal.

enter image description here

  • 1
    Great answer, really easy to follow. How would one make a shortcut for switching to the next/previous tab? This would help immensely. – programstinator Sep 15 '14 at 12:24
  • What window theme are you using? Really like it – xoner Feb 6 '15 at 8:37
  • Thats I am not using right now. Its long ago. not sure I didnt remember the name.@xoner – rɑːdʒɑ Feb 8 '15 at 5:38
  • 1
    There is no need for xdotools. ctrl+shift+t opens a new tab in the default ubuntu terminal with no modifications necessary. – user137717 Aug 27 '15 at 20:13
  • 1
    @user137717 the question does ask for a command line, not a keyboard shortcut, therefore you need xdotools. – humanityANDpeace Aug 29 '16 at 10:37
77

In Gnome Terminal Emulator just use Ctrl+Shift+T

You can check and change this and other key combinations in Edit menu.

  • 7
    The question searches for a command and not for a shortcut. – BuZZ-dEE Jan 2 '14 at 9:33
  • I'd love to be able to cntrl+tab between the tabs – Jamie Hutber Mar 15 '16 at 11:14
  • 1
    @JamieHutber You can use Ctrl+PgUp and Ctrl+PgDn – wjandrea Sep 11 '17 at 3:32
23

in the terminal the shortcut key is

Ctrl + Shift + T

this shortcut can also be edited

  • 2
    that is not a command line solution, but a keyboard shortcut. – humanityANDpeace Aug 29 '16 at 10:36
  • 1
    hwo to switch between tabs in terminal ? – Indrajeet Gour Sep 15 '16 at 19:31
  • 4
    For switching tabs between terminal use CTRL + PAGEUP/PAGEDOWN – iec2011007 Sep 16 '16 at 8:13
19

New tab Ctrl + Shift + T

Close tab: Ctrl + Shift + W

Switch tab: Ctrl + Pg Up and Ctrl + Pg Dn

Move tab: Ctrl + Shift + Pg Up and Ctrl + Shift + Pg Dn

  • Where are the command line commands? – Hans Janssen Aug 10 '18 at 9:12
2

Huh, I do this to fork a build process. package.sh builds and uploads docker images - so I prefer them to overlap. gnome-terminal has some command line options to make new tabs:

#!/bin/bash
BRANCH=${1?choose an environment e.g. stage, demo, production}

if [ -x "$(command -v gnome-terminal)" ]; then
  # run in parallel for gnome-terminal
  gnome-terminal \
  --tab --working-directory=`pwd` --command "zsh -is eval './package.sh app1 $BRANCH'" \
  --tab --working-directory=`pwd` --command "zsh -is eval 'sleep 75  && ./package.sh app2 $BRANCH'" \
  --tab --working-directory=`pwd` --command "zsh -is eval 'sleep 150 && ./package.sh app3 $BRANCH'" \
  --tab --working-directory=`pwd` --command "zsh -is eval 'sleep 225 && ./package.sh app4 $BRANCH'" \

else
  # run one at a time for bash
  ./package.sh app1 $BRANCH
  ./package.sh app2 $BRANCH
  ./package.sh app3 $BRANCH
  ./package.sh app4 $BRANCH

fi
1

Use package ttab

Edit like this

ttab 'cd /Users/chenkai/gh/g-imagery-api && npm run dev '
  • 4
    Please, provide a more detailed answer, include more specific commands and not just link to another solution. – Philippe Delteil Apr 3 at 14:42
1

If you want to open a new tab to a specific directory:

  1. Set the shortcut to Switch to Last Tab in your terminal Preferences.

  2. Put the shortcut to the command below.

    gnome-terminal --tab --working-directory=$HOME/path/to/the/dir; xdotool key <Switch to Last Tab shortcut>
    

Make sure you have xdotool installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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