I recently switched from bash to zshell but my history does not seem to be working. when I press the up arrow I don't get the previous commands. Is the shortcut different? Also how do I enable shared history through tabs and new windows? I am on Lion, and using the standard Terminal
ZSH Shell history not working
Asked Answered
Add this to your .zshrc
:
SAVEHIST=1000 # Save most-recent 1000 lines
HISTFILE=~/.zsh_history
couldn't figure out why
setopt inc_append_history share_history
wasn't working. This fixed it. –
Garnes Wow, this worked for me as well. Can you put this as an answer? –
Esplanade
What does
SAVEHIST=10
do? –
Defamation eivindml, it controls max number of records in history, I believe. –
May
@DimiDak, sure. Of course, value can be increased. Check zsh.sourceforge.net/Guide/zshguide02.html for more info (particularly 2.5.4). –
May
To add to user RoboSloNE, if you've double checked that you have set SAVEHIST and HISTFILE via:
$echo $HISTFILE
~/.zsh_history
$echo $SAVEHIST
100
Then the next step is to check the permissions of the HISTFILE:
$ls -l $HISTFILE
-rw------- 1 user staff 3722 Aug 8 11:29 /Users/user/.zsh_history
Your user need to have read/write access on this file to use it as your history file. I've noticed that installing oh-my-zsh as root will set this file permission to root, so you'll need to:
$chown user:group $HISTFILE
When I run
echo $SAVEHIST
, I get zsh: command not found: 10000
. Nothing gets written to my $HISTFILE
. How can I solve this? –
Hyatt What is the group here? –
Ushijima
I have resolved zsh history using setup below vim ~/.zshrc
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
But I have issue with reading from history. I need to cleanup file manually ~/.histfile
and then start to work.
Hope this help you a bit.
If all of these didn't work, my suggestion is to check the authority of the file ~/.zsh_history
.
For example, enter
sudo chmod 777 ~/.zsh_history
that's a horrible idea. why would you want the world to be able to read your history, which includes typos and other stuff. Moreover,
chmod 777
means it's executable anyone can write to it. That means another user can write to a file in your home directory and you could accidentally run it and it could be destructive. –
Webbed © 2022 - 2024 — McMap. All rights reserved.