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 && ${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 && ( ${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.
/etc/bashrc
. You may need to find someone to adapt that for tcsh. Elsewhere on Stack Exchange I posted equivalent code for zsh.$TERM_SESSION_ID
to a unique ID; its exact value is subject to change, but it is currently a UUID. When restoring, it restores this ID. For example, you can use the ID to generate a file pathname and save data in it, then read it back in when the shell starts. You'll probably want to periodically delete old session data, since you don't know if a session will ever be restored again.