~kris/dots

srice

65bd807cfdd6651a480f8fc70ed41ef82abaf64b — Kris Yotam 2 months ago 512b738
mksh: skip stale history log on first prompt render
1 files changed, 7 insertions(+), 0 deletions(-)

M .mkshrc
M .mkshrc => .mkshrc +7 -0
@@ 48,7 48,14 @@ else
	# mksh: no DEBUG trap / PROMPT_COMMAND. Log from PS1 each prompt.
	# The leading $(...) captures $? first, so the exit code is accurate,
	# and _kh_prompt emits nothing so the visible prompt is unchanged.
	# Skip the first render: at shell start fc -ln -1 is a stale HISTFILE
	# entry, not a command run this session.
	_kh_first_prompt=1
	_kh_prompt() {
		if [ -n "$_kh_first_prompt" ]; then
			unset _kh_first_prompt
			return
		fi
		_kh_log "$(fc -ln -1 2>/dev/null | sed 's/^[[:space:]]*//')" "$1"
	}
	PS1='$(_kh_prompt "$?")'"$PS1"