From 404c9592ecd86f355f1d50b2ac7d4f6c11027aa0 Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Mon, 15 Apr 2019 15:04:30 +0200 Subject: [PATCH] Add histmode on/off commands. --- dotfiles/zshrc.d/history.zsh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 dotfiles/zshrc.d/history.zsh diff --git a/dotfiles/zshrc.d/history.zsh b/dotfiles/zshrc.d/history.zsh new file mode 100644 index 0000000..88da6b6 --- /dev/null +++ b/dotfiles/zshrc.d/history.zsh @@ -0,0 +1,26 @@ +histmode() { + # This is very brittle as it assumes we're the only user of fc + case "$1" in + on) + if [ "$HISTDISABLED" -ne 1 ] ; then + echo "History is not disabled." >&2 + return 1 + fi + fc -P + HISTDISABLED=0 + echo "History enabled." + ;; + off) + if [ "$HISTDISABLED" -eq 1 ] ; then + echo "History is already disabled." >&2 + return 1 + fi + HISTDISABLED=1 + fc -p /dev/null $HISTSIZE 0 + echo "History disabled." + ;; + *) + echo "Unknown command." >&2 + ;; + esac +}