I'm not talking about closing the terminal window itself which you can easily do by using the exit
command. I'm talking about closing a tab that you have originally opened up by pressing the CtrlShiftT key combination. When I'm done working with it, I would like to close it down without lifting my hands up from the keyboard and going for the mouse to click that small X button. Is there a command for that?
When the shell process inside the terminal tab exits, it will close. If it was the only tab, the entire window will close. So you just have to quit the Bash session.
Your Bash session quits...
exit
.EOT
("End Of Transmission") code.Note that it must be pressed when the command prompt is empty, i.e. you haven't typed anything else on that line yet.
Please also note that you can nest multiple interactive shells. You can start a new shell inside the current one by running e.g.
bash
,sh
,python
,bc
, ... Theexit
and Ctrl+D will always only terminate the currently active shell, which is usually the innermost one.From the GNOME Terminal help:
You already mentioned it, type exit and the tab (as well as the terminal session running within the tab) will be closed.
Like @YiboYang mentioned in comments, it is not possible to do
Ctrl + W
orexit
in some cases:That shorcut can be viewed/changed from the Menu bar, via File>Terminal>Preferences>Shortcuts
GNOME terminal preferences
It is highlighted in the image above. Double-click on the Shortcut key and simple key-in a new combination to assign to it,
E.g. I have set mine as
Ctrl + W
to be synchronous with the standard browser shortcut to close a tab.