From e65485fc6c2ac311974d421e3e789e7b0e749e48 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Mon, 9 Dec 2024 20:11:21 -0700 Subject: [PATCH] fish: Add fix_fish_history Signed-off-by: Nathan Chancellor --- fish/functions/fix_fish_history.fish | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 fish/functions/fix_fish_history.fish diff --git a/fish/functions/fix_fish_history.fish b/fish/functions/fix_fish_history.fish new file mode 100644 index 00000000..fa2f6976 --- /dev/null +++ b/fish/functions/fix_fish_history.fish @@ -0,0 +1,11 @@ +#!/usr/bin/env fish +# SPDX-License-Identifier: MIT +# Copyright (C) 2024 Nathan Chancellor + +function fix_fish_history -d "Remove NUL bytes to workaround https://github.com/fish-shell/fish-shell/issues/10300" + python3 -c "from pathlib import Path +fish_history = Path.home() / '.local/share/fish/fish_history' +history_bytes = fish_history.read_bytes() +if (nul := b'\x00') in history_bytes: + fish_history.write_bytes(history_bytes.replace(nul, b''))" +end