You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When attempting to clear the history completely, you run history -c or its equivalent omz_history -c. This clears the history file completely as intended.
When attempting to not save history for the current session but not tampering with the history file, you would run history -p.
However, when attempting to run history -p with ohmyzsh this results in running builtin fc -l "$@" 1. Here "$@" is set to -p which results in builtin fc -l -p 1. This indeed does not save the current session history to the original history file. However:
What this causes is that the HISTFILE environment variable is overwritten with the value 1. A file named 1 is automatically created in the current working directory and the session history is stored in it. Any attempt to remove the file within the session will result in it being recreated whenever any interactive command is executed until the session is exited.
When the session is exited, the file still exists.
I came up with the same conclusion, replacing the else block with builtin fc -l "$@". That way the user can have some control over the underlying fc call and at the same time users executing just history are not left out.
Describe the bug
In bash, in order to not save the history for the current session you use
history -c
. To do the same in zsh you usehistory -p
instead.Using ohmyzsh,
history -c
clears the history file completely instead of just not saving the history for the current session.The history file path is stored in the
HISTFILE
environment variable. By default, it's the$HOME/.zsh_history
file.When using oh-my-zsh,
history
is aliased to theomz_history
function. which is defined as follows:ohmyzsh/lib/history.zsh
Lines 2 to 18 in bf713e2
When attempting to clear the history completely, you run
history -c
or its equivalentomz_history -c
. This clears the history file completely as intended.When attempting to not save history for the current session but not tampering with the history file, you would run
history -p
.However, when attempting to run
history -p
with ohmyzsh this results in runningbuiltin fc -l "$@" 1
. Here"$@"
is set to-p
which results inbuiltin fc -l -p 1
. This indeed does not save the current session history to the original history file. However:What this causes is that the
HISTFILE
environment variable is overwritten with the value1
. A file named1
is automatically created in the current working directory and the session history is stored in it. Any attempt to remove the file within the session will result in it being recreated whenever any interactive command is executed until the session is exited.When the session is exited, the file still exists.
References:
Steps to reproduce
1
.echo $HISTFILE
should result in$HOME/.zsh_history
by default.history -p
echo $HISTFILE
results in1
.ls
you find a file called1
.Expected behavior
history -p
unsets theHISTFILE
environment variable.Screenshots and recordings
OS / Linux distribution
macOS Sonoma 14.4.1
Zsh version
5.9
Oh My Zsh version
master (bf713e2)
Terminal emulator
iTerm2
If using WSL on Windows, which version of WSL
None
Additional context
No response
The text was updated successfully, but these errors were encountered: