11

how does one "undo close-tab" in terminal? And quite related to it, is it possible to remember a session of tabs in terminal?

I mean (alike Firefox) if I close all tabs in a particular terminal window, how do I open with same the next day?

Its really useful to remember the terminal session for people like me who use multiple tabs a lot, and do not wish to start the next day with remembering what (and whereall) one was working, when one left the desk the day before.

In mouse right-click menu of gnome-terminal, one could easily (and I have) mistakenly click close tab instead of 'Copy'and lost track of what and where one was before selecting the text selected. In this case, undo closed-tab will serve a great purpose (available in Firefox already)

Thanks!

--V

kvaibhav
  • 143
  • 1
  • 7

4 Answers4

7

For the gnome terminal, you can use

gnome-terminal --profile=〈your profile〉 --save-config=〈file〉

I launch it as a background task to save the terminal state periodically.

Ivaylo Slavov
  • 8,179
  • 10
  • 57
  • 103
ChriS
  • 71
  • 1
  • 2
  • Hi! I tried this, and got the following error! Any comments? `gnome-terminal --profile=Default --save- config=~/.terminal.save.test Failed to forward arguments: GDBus.Error:org.gtk.GDBus.UnmappedGError.Quark._g_2dfile_2derror_2dquark.Code4: Failed to create file '/work/bkp.aka/organic/~/.terminal.save.test.S9BJXW': No such file or directory` – kvaibhav May 20 '13 at 05:25
  • 2
    @kvaibhav - just tested on Ubuntu 11.04, GNOME Terminal 2.32.1, and the problem is use of tilde `~` in the arguments; note that it expands both to your home dir _and_ an extra tilde in `/work/bkp.aka/organic/~/...`. I got the same error when I used the tilde, but using a full path instead: `gnome-terminal --profile=mini --save-config=/home/username/.terminal.save.test` worked fine for me, and config file gets saved. Also, `--profile` in this version is not listed in `--help`, but it works (when starting, not for saving config). Hope this helps - cheers! – sdaau Nov 16 '13 at 12:27
  • For gnome-terminal 3.6.2 on Ubuntu 14.04, `--profile` has no affect, that is `--save-config` works as though `--profile` was not given.. – Håkon Hægland Apr 06 '15 at 05:46
6

"termit" can save sessions and is scriptable in lua: https://github.com/nonstop/termit/wiki I don't know about an "undo close tab" feature, though.

For reference, my termit lua config can be found here: https://github.com/thet/dotfiles-termit

thet
  • 659
  • 8
  • 13
5

On Linux, gnome-terminal is able to load multiple tabs with different working directories. Like termit (which is much more flexible due to it's lua scripting interface), it doesn't have a "undo close tab" feature.

Open Gnome terminal with multiple tabs, each one in another working directory: gnome-terminal --tab --working-directory=/home --tab --working-directory=~ --tab --working-directory=/opt.

Open Gnome terminal with multiple tabs and one base working directory: gnome-terminal --working-directory=/home --tab --tab --tab.

For more options do: gnome-terminal --help-all.

thet
  • 659
  • 8
  • 13
4

The gnome terminal doesn't have such features, but if you're open to change you could try konsole, it has some nice 'save session' options you could find helpful, though nothing about re-opening accidentally closed tabs, as far as I know.

The other thing, if you're particular about your desktop, is that KDE's konsole might not fit all too well within Gnome.

brunn
  • 1,135
  • 1
  • 16
  • 34
  • 2
    Konsole dropped the 'save session' feature in recent versions. What you now have is the command option **--tabs-from-file**. It allows you to define multiple tabs with specific title, workdir, command and shell profile in a file. Check the [Command-line Options](https://docs.kde.org/stable5/en/applications/konsole/command-line-options.html) sections of the Konsole docs for an example and specs. – SleighBoy Oct 21 '16 at 22:30