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

Re: some way to inherit kill ring in su'd shell?



On 2009-01-07 at 22:49 -0500, Greg Klanderman wrote:
> Is there some way to have the shell started by su inherit
> the kill ring from the parent shell?

Grotesque and there's probably a more elegant way which I'm missing, but
you could rebind ^M from accept-line to a custom widget which does some
dispatch checks before calling the accept-line widget; your custom
widget checks for the first word not containing '=' within it and takes
that as the command-word (also handle leading '-' appropriately, as
appropriate for your command-line style).

You then dispatch on the command-word; if it's su then you dump the
contents of the killring array variable (available in widget context)
with 'typeset -p killring' to a file with a fixed name in a place only
writable by the invoking user but readable by the recipient user -- be
very careful of FS attacks here.  In the target user shell startup
(.zshrc), do something like check if the file is less than a minute old
and, if so, source it.  Preferably with some paranoid ownership checks
too.

-Phil



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