From dbfd854ae30f6f048de7c8dd311399896c62796e Mon Sep 17 00:00:00 2001 From: Yogeshwaran Rajendran Date: Mon, 22 Jul 2024 11:13:40 +0530 Subject: [PATCH] fix(history): add warning before deleting command history in `history -c` (#12472) --- lib/history.zsh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/history.zsh b/lib/history.zsh index 35da57de2..b13e1807f 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -9,8 +9,9 @@ function omz_history { # confirm action before deleting history print -nu2 "This action will irreversibly delete your command history. Are you sure? [y/N] " - builtin read -E - [[ "$REPLY" = [yY] ]] || return 0 + builtin read -k1 + [[ "$REPLY" = $'\n' ]] || print -u2 + [[ "$REPLY" != ([nN]|$'\n') ]] || return 0 print -nu2 >| "$HISTFILE" fc -p "$HISTFILE"