Is it possible to open a new tab in the current terminal with some commands?
9 Answers
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.
-
1Great answer, really easy to follow. How would one make a shortcut for switching to the next/previous tab? This would help immensely. Sep 15, 2014 at 12:24
-
-
Thats I am not using right now. Its long ago. not sure I didnt remember the name.@xoner– rɑːdʒɑFeb 8, 2015 at 5:38
-
1There is no need for xdotools. ctrl+shift+t opens a new tab in the default ubuntu terminal with no modifications necessary. Aug 27, 2015 at 20:13
-
2@user137717 the question does ask for a command line, not a keyboard shortcut, therefore you need
xdotools
. Aug 29, 2016 at 10:37
In Gnome Terminal Emulator just use Ctrl+Shift+T
You can check and change this and other key combinations in Edit menu.
-
10
-
-
2
in the terminal the shortcut key is
Ctrl + Shift + T
this shortcut can also be edited
-
4that is not a command line solution, but a keyboard shortcut. Aug 29, 2016 at 10:36
-
1
-
4
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
-
2Where are the command line commands?– user723790Aug 10, 2018 at 9:12
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
-
5Please, provide a more detailed answer, include more specific commands and not just link to another solution. Apr 3, 2019 at 14:42
If you want to open a new tab to a specific directory:
Set the shortcut to Switch to Last Tab in your terminal Preferences.
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.
Open the terminal
maximize it (or just click the terminal window)
at top bar, click Terminal-->Preferences
under General option, switch Window to Tab
after that, whenever you want to open new terminal, RightClick in the terminal --> Open Terminal
The way i usually want to do this is when i start typing cd some/directory/to-switch-to
and then i realize i would much rather open that directory in a new tab. This function will open a new tab in the same directory if no path is specified, and in the specified directory (absolute, home-relative, or current directory relative) if one is supplied, with much credit to @wolcen.
tcd() {
if [ -d ${PWD}/$1 ]; then
gnome-terminal --tab --working-directory=${PWD}/$1
else
gnome-terminal --tab --working-directory=$1
fi
}
Usage example:
tcd some/directory
Now if i've finished typing a cd
command i can press ctrl+a
and t
and ENTER
to instead open the directory in a new tab with just a few keystrokes.