zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: zsh generates invalid UTF-8 encoding in the history
Date: Thu, 6 Oct 2016 11:31:12 -0700	[thread overview]
Message-ID: <161006113112.ZM16191@torch.brasslantern.com> (raw)
In-Reply-To: <CAHYJk3TvMyW05V7aXOvX2s1u-BMtFCx6-4GBRHj25FeJ_OBaDg@mail.gmail.com>

On Oct 5,  2:41pm, Mikael Magnusson wrote:
}
} History entries are written in metafied form to the history file. You
} can use the 'history' command to print a readable version of history,
} or use this small utility http://mika.l3ib.org/code/unmetafy.c

Nice little utility, but it doesn't handle converting "\\\n" into "\n".
Maybe that's not desirable anyway, as the downstream utility might
want to do that itself.

To unmetafy with the shell (including backslash-newline processing):

    () { fc -pa $HISTFILE $SAVEHIST && fc -rnl -1 1 }

Or more generically

    unmetafy() {
      () { fc -pa $1 ${$(wc -l $1)[1]} && fc -rnl -1 1 } ${1:-=(cat)}
    }

Vincent might also consider using a zshaddhistory hook to maintain a copy
of the history file that is unmetafied and stripped of extended-history
markup, though that gets a bit more complicated.


  reply	other threads:[~2016-10-06 18:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05 11:48 Vincent Lefevre
2016-10-05 12:41 ` Mikael Magnusson
2016-10-06 18:31   ` Bart Schaefer [this message]
2016-10-07  8:57     ` Vincent Lefevre
2016-10-07 17:01       ` Bart Schaefer
2017-11-29 15:46         ` Vincent Lefevre
2016-10-05 17:25 ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=161006113112.ZM16191@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).