How do I make terminal sessions resume on Lion with iterm2 and tcshrc My understanding is that with Lion my terminal windows should restore their state.  However, this does not happen for me.  I wonder if this is because I use tcsh instead of bash?

Is there something I can do to make my iterm2 sessions resume where they left off?

My current attempt to do this has been to use

 alias precmd 'if ( $?TERM_PROGRAM &amp;&amp; ${TERM_PROGRAM} == "iTerm.app" ) /opt/local/libexec/gnubin/echo -ne "\033];$cwd\007"'
 set prompt = '%{\e]2;%~\a%}%S[%m:%c3] %n%#%s '


But this sets only the labels of the tabs.  The label of the window gets the abbreviated filenames with ~ in place of the full filename.  I don't know if this is related to my failure to get terminal resumption.  At any rate, when I quit and restart all my terminal windows and tabs are back in my home directory.

Extra bonus points would be a solution that is sensitive to use of slogin.

I am unable to get the correct resumption behavior with the built-in Apple Terminal, either, when I change the above to

if ( $?TERM_PROGRAM &amp;&amp; ( ${TERM_PROGRAM} == "iTerm.app" || ${TERM_PROGRAM} == "Apple_Terminal") ) then
  alias precmd ' /opt/local/libexec/gnubin/echo -ne "\033];$cwd\007"'
  set prompt = '%{\e]2;%~\a%}%S[%m:%c3] %n%#%s '
endif


I don't return to the same working directory, and while I can see the command history, I cannot use it (I can't use ^P to move up, e.g., and the history command returns nothing).  So I believe somehow this is not working with tcsh, as opposed to bash.  My colleagues assure me that they don't lose the working directory upon application exit.
You could add something like this to the startup script of your default shell (mine is zsh, most people use bash, I guess, so you may have to tweak.)

Here's my bit of screen jiggery-pokery (in my .zshrc)

# Autoload screen if we aren't in it.  (Thanks Fjord!)
if [[ $STY = '' ]] then screen -xRR; fi


I got this from somewhere on the interwebs (I don't recall where, and I don't know who Fjord is, but good on him.

With this you can close your iTerm window, and it will resume where you left off when you reopen it.  I highly recommend reading the screen man page also.