Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
    
"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 '12 at 21:27
    
don't repost. if you haven't gotten any answers on Super User then add a bounty onto it. –  Sathya Jan 1 '13 at 18:17
add comment

2 Answers

up vote 4 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.