Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ZSH Shell history not working

Tags:

zsh

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

like image 342
Trt Trt Avatar asked Sep 05 '12 12:09

Trt Trt


People also ask

How long is zsh history?

Increasing the History File Size Unfortunately, zsh's default history file size is limited to 10000 lines by default and will truncate the history to this length by deduplicating entries and removing old data. Adding the following lines to . zshrc will remove the limits and deduplication of the history file.

How do you delete history on zsh?

In my terminal, ZSH, there's a file called ~/. zsh_history , and a similar one for Bash. To remove the command, open that file and remove the entry from the list. Open a new terminal window, and the bad command is gone.


2 Answers

Add this to your .zshrc:

SAVEHIST=1000  # Save most-recent 1000 lines HISTFILE=~/.zsh_history 
like image 188
roboslone Avatar answered Nov 11 '22 23:11

roboslone


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 
like image 24
Rick Hanlon II Avatar answered Nov 11 '22 23:11

Rick Hanlon II