5

I have opened many files in vim and there I am editing and tracing the program flow using ctags and I don't want to lose all those info in next reboot, I can't keep my system on for few weeks or months.

Is there any way to save current terminal state or/and vim stack state?

Here is similar question

2
  • "tracing the program flow using ctags"? ctags is used to index your codebase. Once the tags file is created, it doesn't matter at all if you log out or turn your machine off.
    – romainl
    Dec 31, 2012 at 21:27
  • don't repost. if you haven't gotten any answers on Super User then add a bounty onto it.
    – Sathyajith Bhat
    Jan 1, 2013 at 18:17

2 Answers 2

4

Read :help :mksession.

:mksession /path/to/sessionfile

This command writes a script that you can run later with

:source /path/to/sessionfile

You can run these commands automatically when you leave and launch Vim with an autocmd. Read this page on the Vim wiki for ideas.

Saving a terminal session is a different problem. Both tmux and screen allow you to deattach/reattach sessions but I admit I don't know if they can survive a reboot.

edit

This answer explains how to script your tmux session and restore it later. Something along that line could probably be done for screen.

If you don't use tmux or screen, you are left with the capabilities of your terminal emulator.

3

I had to work on the same problem - unfortunately many applications do not even have a way to save their state in a controlled manner, let alone when terminated on system shutdown.

My current solution:

  • Hibernation covers 99% percent of cases for all my laptop and desktop computers. I can generally power down the computer and everything will be restored on power-on - It is generally far more stable on my systems than Suspend-to-RAM, since it does not depend on the BIOS doing the Right Thing (TM).

    The only problem with hibernation is that it cannot be used when booting to a different kernel, although I would not expect most people to be updating their kernel all that often...

  • Scripting: Rather than try to get my applications to save their state, I chose instead to create a number of scripts to launch gnome-terminal and screen with a preset selection of initial tabs/screens and associated programs that work for me. Basically I have almost eliminated the 10-minute hassle of launching my standard set of terminals, file browsers e.t.c. after I log-on to my desktop.

Considering the state of most applications, especially in the console, I do not believe that it can get much better than this. Anything more would have to be treated on an case-by-case basis for each application. For example, some applications, such as Eclipse, can be configured to save their state periodically.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .