Will any (recent) Linux terminal emulator allow me to save my session (tabs, history, etc)?

6

3

Over time, I become invested in my terminal sessions: tabs, command history, window layout and title, etc. Eventually, a reboot requires me to start all over again which wastes my time.

The two terminal emulators with which I'm familiar had at least partial capability here, but the functionality has since been removed: konsole lost this functionality somewhere along the way to KDE4. gnome-terminal lost the --save-config option as "obsolete" somewhere before version 3.10.2, i.e. the answer here no longer applies: Save multiple gnome-terminal layout?

I want to capture the current state of all terminal sessions and restore them after a reboot. A scripted solution would be fine, so long as it does not require manual updates to track session changes.

srking

Posted 2014-05-20T18:48:44.337

Reputation: 161

I've been looking for exactly this for ages. I have exactly the same problem as the OP - I have 20-30 tabs up for months, then I have to reboot and I don't want to waste all the tabs individual history, path prompts etc. But I guess this is what open-source is about, we can take Terminator and add the per-tab HISTFILE stuff :) – BjornW – 2014-09-21T12:26:14.137

1

Define "state". For example, if you are reading a file with less, do you want that same file to be remembered next time you open your terminal or do you just want the tabs/panes set up and the relevant programs launched? Would something like my answer here work for you?

– terdon – 2014-05-20T22:14:22.210

1State means: windows, tabs, command history, window layout, window & tab titles. I do not need to save state for arbitrary processes running in the terminal session, e.g. "less". Even bash needs some coaxing here, since command history is not saved per instance without some tricks. I'll check your link. The closest I've found so far is Konsole bookmarks. – srking – 2014-05-20T23:54:17.773

In that case, terminator can do it as I explain in the link I gave in my previous comment. Let me know if you need anything else and I'll tweak it accordingly and post as a new answer here. If not, I will vote to close this as a duplicate. – terdon – 2014-05-20T23:59:43.017

1@terdon, Thanks, I'm glad to know about terminator. After briefly experimenting, there are shortcomings for me: (1) does not save bash history per shell, and (2) can't rename tabs? I suspect I can't do what I want without rolling some fragile scripts. – srking – 2014-05-21T00:49:12.697

>

  • Nothing will save bash history per shell. That's not how it works, that doesn't depend on the terminal emulator but on the history function of bash itself. How would that work? Would you like the history command to give different output on each of the separate panes? If so, then no. 2) Yes, it does not name them. You could work something out with a echo -ne "\033]0;FOO\007" which would set the title toFOO` but I don't think terminator itself can do this (that command is terminal agnostic, it's a bashism. For more see here)
  • – terdon – 2014-05-21T00:58:22.117

    1@terdon: Yes, bash-isms are required for history save/restore, but this could work when each bash shell has its own unique HISTFILE. The terminal program could help in this regard by allowing history setup commands to run at startup. It looks like Terminator allows per-shell startup, but it's a brain and labor intensive process for novice users. A canned solution guided via a GUI would be ideal. – srking – 2014-05-21T16:23:07.823

    Ah, yeah, I see what you mean. You'd have to export HISTFILE='foo' for each tab. Sorry, no idea about a GUI way, I've never needed to do this. If you don't get any useful answers here after a while, flag for mod attention and ask them to migrate to [unix.se]. You might have better luck there. Make sure you include the clarifications you've given in the comments about what exactly you need. – terdon – 2014-05-21T16:29:20.377

    Answers

    1

    Here is an xfce terminal fork, with possibility to save/restore session just from menu: https://github.com/repu1sion/xfce4-terminal

    pulse

    Posted 2014-05-20T18:48:44.337

    Reputation: 11

    1

    this isn't exactly what you asked for but tmux has such capabilities.

    Just make sure to install the tmux-resurrect plugin along with it, which allows for restoring the tmux environment (windows, splits, and certain running programs) after a restart.

    On the bright side, tmux will work with all

    sgp667

    Posted 2014-05-20T18:48:44.337

    Reputation: 563

    0

    I guess that this is not really an answer to your question, but this is how I had it set up:

    A bunch of scripts which would open different "Gnome-Terminal presets".

    For example, in this script, I open gnome-terminal with three tabs, and call SSH with parameters in each one.

    #!/bin/sh
    PATH=/usr/bin:/bin 
    
    gnome-terminal \
    --tab -t CustomTabText1 -e 'sh -c "ssh hostname.one"' \
    --tab -t CustomTabText2 -e 'sh -c "ssh hostname.two"' \
    --tab -t CustomTabText3 -e 'sh -c "ssh hostname.three"'
    

    I also used ssh config file heavily to reflect specific host SSH parameters. Of course, if you need an exception, just pass the parameters to SSH in the gnome-terminal script, which will take precedence over the SSH config file.

    Kaurin

    Posted 2014-05-20T18:48:44.337

    Reputation: 685

    For running simple commands such as "ssh machine" you do not need running a shell (sh -c).

    It is needed to perform redirections and pipelining, wildcard expansion, conditionals etc. but not for running plain commands. – Raúl Salinas-Monteagudo – 2014-11-06T10:22:51.203