Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for OS X Lion's restore windows after quit #522

Closed
wants to merge 2 commits into from
Closed

Add support for OS X Lion's restore windows after quit #522

wants to merge 2 commits into from

Conversation

rgm
Copy link

@rgm rgm commented Aug 3, 2011

By default, Lion's Terminal.app will re-open all windows after quitting and
restarting the app, but only in bash using a chpwd hook found in /etc/bashrc.
See also http://superuser.com/questions/313650/resume-zsh-terminal-os-x-lion

By default, Lion's Terminal.app will re-open all windows after quitting and
restarting the app, but only in bash using a chpwd hook found in /etc/bashrc.
See also http://superuser.com/questions/313650/resume-zsh-terminal-os-x-lion
@ashmoran
Copy link

ashmoran commented Aug 5, 2011

I found this via the superuser.com link. I tried the patch in this pull request in my own zshrc, but it didn't work on my Lion zsh 4.3.11. I had to made the following changes:

if [[ $TERM_PROGRAM == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
# ...
fi

ie: replace "Apple Terminal" with "Apple_Terminal", and change the use of braces to "then / fi"

Any thoughts? Is this just because I'm not using oh-my-zsh?

@rgm
Copy link
Author

rgm commented Aug 5, 2011

Apparently I can neither type accurately, nor remember the subtleties of the zsh "if" statement.

@ashmoran
Copy link

ashmoran commented Aug 5, 2011

No problem, I don't really know what I'm doing when I'm programming zsh either :-)

@ashmoran
Copy link

ashmoran commented Aug 6, 2011

I just started using ohmyzsh today and it's amazing! I've thrown out my old hacky scripts. Hopefully this will get merged soon and it will be damn near perfect!

@ashmoran
Copy link

Is it me or is this functionality now available on Lion in master without the contents of this pull request? (This is showing as open, so I assume it wasn't merged)

@rgm
Copy link
Author

rgm commented Aug 12, 2011

Doesn't work for me in robbyrussell/master (be2ab22)

Is it possible you tried the rgm/master fork? I have merged it in there. I have to maintain it in a separate branch for the pull request, since my master doesn't cleanly merge to robbyrussell/master right now.

@ashmoran
Copy link

Apparently I was imagining it :-S I just checked and it's not re-opening the directories. Sorry for the noise! Hopefully this will get merged soon, as when I re-open Terminal on Lion I have to press just to see the prompt

@sorin-ionescu
Copy link
Contributor

The OS X plugin is not the proper place to put this. It needs to go where the terminal window and tab titles are set; otherwise, you'll get duplicates. I've taken care of this in my extensive rewrite of OMZ.

I wonder why you have added all those authors in the header. I haven't used any of their code.

@rgm
Copy link
Author

rgm commented Sep 12, 2011

Clearly, I should have read the actual git blame instead of doing a git blame FILE | cut -f 3-4 -d ' '. Oops.

Would you educate me a little more on this point? I'm having trouble finding where the Lion resume code is in your fork. I'm sure it could be improved, but this patch has been working OK for me.

@sorin-ionescu
Copy link
Contributor

I have not pushed yet. :) Here's the snippet.

# Sets the tab and window titles before the prompt is displayed.
function set-title-precmd {
  if [[ "$TERM_PROGRAM" != "Apple_Terminal" ]] && check-bool "$AUTO_TITLE"; then
    set-window-title "${(%):-%~}"
    for kind in tab screen; do
      # Left-truncate the current working directory to 15 characters.
      set-${kind}-title "${(%):-%15<...<%~%<<}"
    done
  else
    # Set Apple Terminal current working directory.
    printf '\e]7;%s\a' "file://$HOST${PWD// /%20}"
  fi
}
add-zsh-hook precmd set-title-precmd

This has nothing to do with resume per se. It's just how Terminal.app is informed of the address of the current working directory. When it knows the current working directory, Terminal.app lets you open Finder windows from the title bar and resume to the previous working directory.

@rgm
Copy link
Author

rgm commented Sep 13, 2011

Ah, OK. Where would you stick this, /lib/termsupport.zsh ?

@sorin-ionescu
Copy link
Contributor

No, this is just an incomplete snippet. My OMZ fork has been heavily rewritten in relation to #377. I'm almost done, just a few more rebases, and I'll announce it.

@rgm
Copy link
Author

rgm commented Sep 13, 2011

OK. Looking forward to it.

@blaenk
Copy link

blaenk commented Sep 24, 2011

@ashmoran said:

when I re-open Terminal on Lion I have to press just to see the prompt

I am having this issue as well. As someone new to zsh as well, these two problems lead me to spend a few hours trying to figure out what I could have possibly misconfigured.

Thankfully it seems like @sorin-ionescu is almost done with the rewrite.

ericlake pushed a commit to ericlake/oh-my-zsh that referenced this pull request Feb 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants