Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Editing the history in the shell
- X-seq: zsh-workers 45899
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: Editing the history in the shell
- Date: Sat, 23 May 2020 02:28:07 +0000
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- In-reply-to: <CAH+w=7ZFt7jshjv1FCEbmP_PgADvdKwymRutrzwJAvzNpsfOmA@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAH+w=7ZFt7jshjv1FCEbmP_PgADvdKwymRutrzwJAvzNpsfOmA@mail.gmail.com>
Bart Schaefer wrote on Fri, 22 May 2020 15:24 -0700:
> 1) Should it be possible to edit empty events into the history?
> Currently empty lines are removed, but changing to IFS=$'\n\n' would
> preserve them (thanks Oliver for the idea)
Hmm. I guess they might be useful as separators?
> Patch both inlined and attached in case gmail garbles the lines.
It did.
> +++ b/Functions/Misc/zed
> @@ -133,6 +138,17 @@ if ((fun)) then
> + else
> + hist=$HISTSIZE; HISTSIZE=0; fc -R /dev/null; HISTSIZE=$hist
> + for (( hist=1; hist <= $#var; hist++ )) print -s "$var[hist]"
Evaluating «$#var» takes O(N) time, which makes this an O(N²) loop.
Save $#var into an auxiliary variable?
Also, s/print -s/print -s --/.
> + [[ -n $1 ]] && SAVEHIST=$#var # Resets on function exit
> + fi
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author