Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: idea for new feature (was: Re: sticky-note and zle bindings)



On Jan 16,  6:12pm, Andy Spiegl wrote:
}
} How about saving the current directory (or even the whole directory
} stack) of every zsh-instance so that it's possible to restore the
} status of all shells after an (in)voluntary crash, like network splits
} or an X-server crash.

Of course this is what share_history and inc_append_history are in
part intended to accomplish.

The problem is that zsh can't do it by iself.  So, your X server has
crashed and 20 shell windows went kablooie.  Even if every zsh has
faithfully been recording its state somewhere, how does each new
xterm you launch on the retarted X desktop know which one of the 20
saved states it should restore?

This is actually made *worse* by the fact that many modern X desktops
have "session managers" that will remember the apps and placement of
your windows and re-launch them on restart, so you may have 20 new
xterms all examining the set of state files effectively at once.

Even supposing your session manager doesn't do this, and you have a
command to launch a new xterm for every state file and somehow pass it
(ZDOTDIR maybe?) the name of the file it should initialize, zsh can't
track window placements or much of anything else that would help you
to tell which window is which after they reappear.

The upshot is that this isn't a zsh feature -- it's a cooperative
feature that requires effort from both the shell and whatever other
user interface environment it's running inside.  It's pretty simple
to dump state somewhere from the precmd() function, if only you know
what to do with it later.

One of my sysadmins back in grad school had a collection of csh scripts
read from his .login to do something like this, 20 years ago.  I never
saw them in detail, but I got the impression that they were stashing
away data they'd extracted from the SunWindows environment on his old
Sun-1 desktop (before there was such a thing as a sparc chip or even
OpenWindows -- can you say "black-and-white bitmap"?).  And he didn't
even have such a thing as precmd -- he was relying on aliases for "cd"
and the like.



Messages sorted by: Reverse Date, Date, Thread, Author