Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Ability to set HISTNO to a certain position from within zshrc
- X-seq: zsh-users 6568
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users <zsh-users@xxxxxxxxxx>
- Subject: Re: Ability to set HISTNO to a certain position from within zshrc
- Date: Sat, 13 Sep 2003 23:19:24 +0000
- In-reply-to: <20030913220707.13828.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20030913220707.13828.qmail@xxxxxxxxxxxxxxxxxxxxxxx>
On Sep 13, 3:07pm, Felix Rosencrantz wrote:
}
} I wanted to start in the middle of history not the beginning. So the lines
} above the starting point contain commands that might need to be run, and the
} starting line and following lines contain the likely sequence of commands to
} run.
}
} With the "print -z"/ainh solution I lose the ability to have the leading
} commands.
So use print -z followed by history-search-backward, followed by either
moving up through the history or executing accept-line-and-down-history.
If it's really too much to have to hit one extra key before hammering away
at Enter, set up a keymap (see bindkey -N) in which up-arrow is bound to
a user-defined widget that changes back to the default keymap and then
executes history-search-backward and finally executes up-history, and in
which Enter is bound to a user-defined widget that changes back to the
default keymap and then executes accept-line-and-down-history. Install
that keymap right after your print -z.
} It almost seems like there should be a infer-back-into-history, where it
} determines the inferred line, and jumps to it in history.
Isn't that what history-search-backward does?
} Maybe even an accept-and-down-history-or-infer, which accepts,
} attempts to go down in history, and if at the end of the history,
} attempts to infer the next command.
I think all the tools are available to write this as a user-defined widget.
As a crude stab at it:
aadhoi () {
local buffer="$BUFFER"
if zle down-history
then
zle up-history
BUFFER="$buffer"
zle accept-line-and-down-history
else
zle -U $'\exinfer-next-history\n'
zle accept-and-hold
fi
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author