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

Re: Editing the history in the shell



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