Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: fc in non-interactive shells and vared
- X-seq: zsh-users 12126
- From: Stephane Chazelas <Stephane_Chazelas@xxxxxxxx>
- To: Peter Stephenson <pws@xxxxxxx>
- Subject: Re: fc in non-interactive shells and vared
- Date: Fri, 26 Oct 2007 14:43:52 +0100
- Cc: Zsh Users List <zsh-users@xxxxxxxxxx>
- In-reply-to: <200710261327.l9QDRd9b003931@xxxxxxxxxxxxxx>
- Mail-followup-to: Peter Stephenson <pws@xxxxxxx>, Zsh Users List <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20071026131442.GA5475@xxxxxxxxxxxxxxx> <200710261327.l9QDRd9b003931@xxxxxxxxxxxxxx>
On Fri, Oct 26, 2007 at 02:27:39PM +0100, Peter Stephenson wrote:
> Stephane Chazelas wrote:
> > - I could not use fc to load/save a history file as fc refuses
> > to work in non-interactive shells. Instead, I have to create
> > a history file manually, read it line by line and use print
> > -s to build the history stack.
> >
> > Is there a better way around that?
>
> You can force a script to be run in interactive mode by including "-i"
> in the options to the shell. This may have side effects, however.
Ok, thanks Peter, I will try that.
> > - When "vared" returns, zsh prints a NL character. As I'm on
> > the last line of the screen, this causes the screen to
> > scroll. Is there any way to avoid that? I tried to do a stty
> > onlret, but that doesn't work as vared resets the termios
> > settings.
>
> I suspect this is coming from the trashzle() when ZLE exits. This is
> quite well buried.
>
> I'm too lazy to try it, but if you have a sufficiently recent zsh you
> could try something like
>
> zle-line-init() { stty onlret; }
> zle -N zle-line-init
[...]
I realised it wouldn't work anyway, I had misinterpreted what
onlret was doing. I just found another work around, I do
something like:
accept-and-bye() {
print -r -- "$BUFFER"
stat +link -A pid /proc/self
trap - TERM
kill $pid
}
zle -N accept-and-bye
bindkey '\r' accept-and-bye
bindkey '\n' accept-and-bye
a=
search=$(vared -p "Search: " -eh a)
The /proc/self above makes it Linux specific though (exit
doesn't work: NL is still displayed).
I'll do more experiments by running zsh -c so that I can use $$.
--
Stéphane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author