MediumAfter Editing zsh History, Check the Running Shell Too | by Dongmin Yu | Oct, 2026 | Medium
Sitemap
Dongmin Yu

Dongmin Yu

Cross-platform engineer in Seoul. I build apps and open-source tools, and write about Flutter, React Native, native integrations, and shipping.

Member-only story

After Editing zsh History, Check the Running Shell Too

3 min readOct 17, 2026

Not a Medium member? Read the full story for free.

Press enter or click to view image in full size
A laptop and a disk carry different command streams: editing the file does not replace the running shell’s history.

You edit a command in the history file, inspect the saved text, and find the old command still listed by the open terminal. Checking the file again will not explain that mismatch: zsh also keeps an in-memory history list.

Before trusting a history-editing tool, check what the running shell lists after the edit and what its undo operation restores. The distinction is small enough to demonstrate without touching your real history.

A file path and a history list can disagree

This demonstration starts a separate zsh -f process, unsets HISTFILE, and creates two temporary fixture files. History persistence is disabled with SAVEHIST=0. It never loads or rewrites your real history, and fc -ln lists the fixture commands without executing them.

zsh -f <<'ZSH'
set -eu
unset HISTFILE
HISTSIZE=20
SAVEHIST=0
demo_dir=$(mktemp -d) || exit 1
trap 'rm -f -- "$demo_dir/before" "$demo_dir/after"; rmdir -- "$demo_dir"' EXIT

print -r -- 'echo old-name' > "$demo_dir/before"
print -r -- 'echo new-name' > "$demo_dir/after"
fc -p "$demo_dir/before" 20 0

HISTFILE="$demo_dir/after"
print -r -- 'File selected by HISTFILE:'
cat -- "$HISTFILE"
print -r -- 'Current history list:'
fc -ln 1

fc -p…

--

--

Dongmin Yu
Dongmin Yu

Written by Dongmin Yu

Cross-platform engineer in Seoul. I build apps and open-source tools, and write about Flutter, React Native, native integrations, and shipping.