mirror of
https://github.com/l0ng-ai/tty7.git
synced 2026-11-06 08:15:35 +00:00
zsh escapes every byte in 0x83..=0xA2 (and NUL) as Meta (0x83) followed by the byte xor 0x20 when writing $HISTFILE. tty7 decoded those files with from_utf8_lossy directly, so CJK commands showed up as mojibake or U+FFFD in history search, next to tty7's own clean copy of the same command. Undo the escaping at the byte level, but only for zsh files: by name (.zsh_history, .zhistory) or, for a custom local HISTFILE, by the presence of extended-history lines. bash and fish files are left alone, since valid UTF-8 like `ー` (E3 83 BC) contains 0x83. Also read tty7's own history file as bytes with a lossy decode, so one invalid byte no longer drops the whole file. Fixes #1175