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

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



On Jan 11, 12:57pm, Greg Klanderman wrote:
}
} From within zle, it looks like you can do something like
} 
}   zle copy-region-as-kill <string>
} 
} to populate the cut buffer/kill ring.
} 
} But then you have to do that from a user-defined widget again.

Use the zle-line-init widget.

It's hard to export the kill ring because of limitations on the format
of environment variables; they have to be plain strings and there has
to be some character that will work as a delimiter between elements if
you want to treat them as arrays.  Since just about anything could be
in the killring, there's not much you can do in the way of a delimiters.

So some variant of Phil's idea:

zle-line-init() {
  if [[ $KILLRINGPID != $$ && -f $KILLRINGFILE ]]
  then source $KILLRINGFILE
  fi
  export KILLRINGPID=$$ KILLRINGFILE=$HOME/.zsh-killring-$$
  typeset -p CUTBUFFER killring >! $KILLRINGFILE
}
zle -N zle-line-init

Of course this gets you the killring at the time zle starts up, not
after you've been editing the "su" command line itself.  For that you
would have to override either accept-line or the various kill widgets.
If you really want to pass the killring to a root shell, you'll also
need a secure location for the KILLRINGFILE to live.



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