Zsh shell history getting cleared automatically while using gnome-terminal(.zhistory)

I noticed that my .zhistory file doesn’t have the older commands I gave. It is just a 4.1KB file usually and has around 200lines after noticing the same repeating over some time. This really bugs me. As I always mess up trying to do somthing, this was a reliable source for me to trace my steps.The bashhistory was reliable in this manner( when I was on Ubuntu.)
I use a gnome-terminal on manjaro gnome DE.
My zshrc is at the default configuration.
Is there any way I can prevent this from happening?

Hi @Korosensei, and welcome!

I use ZSH myself and I am unable to find a .zhistory file. However, I did find ~/.zsh_history which is the gistory file, it seems. Might this also be the case there? Otherwise, it might be permissions, so here’s my history file’s permissions:

$ stat .zsh_history

File: .zsh_history
Size: 13606           Blocks: 32         IO Block: 4096   regular file
Device: 10302h/66306d   Inode: 5243630     Links: 1
Access: (0600/-rw-------)  Uid: ( 1000/mirdarthos)   Gid: ( 1000/mirdarthos)
Access: 2021-01-05 14:04:34.776337102 +0200
Modify: 2021-01-05 14:07:58.632729466 +0200
Change: 2021-01-05 14:07:58.632729466 +0200
Birth: 2021-01-05 14:04:34.776337102 +0200

I hope this helps.

Thanks for the reply. Actually I have got a bash_history file.
But the history files I got goes to .zhistory. I haven’t got the .zsh_history in /home.

I just checked again found and found ~/.zhistory. So it’s obvious that it was my mistake, not yours.

Double check that the $HISTFILE environment variable exists and is correct.


Then check if the file exists and it’s permissions are correct:

$ stat $(echo $HISTFILE)

File: /home/mirdarthos/.zhistory
Size: 12086           Blocks: 24         IO Block: 4096   regular file
Device: 10302h/66306d   Inode: 5285510     Links: 1
Access: (0600/-rw-------)  Uid: ( 1000/mirdarthos)   Gid: ( 1000/mirdarthos)
Access: 2021-01-13 08:56:31.657668465 +0200
Modify: 2021-01-13 09:11:08.767260716 +0200
Change: 2021-01-13 09:11:08.767260716 +0200
Birth: 2021-01-13 08:56:31.657668465 +0200

I just found this page regarding zsh history. According to that:

History accepts a range in zsh entries as [first] [last] arguments, so to get them all run history 0 .

To get the zsh help (at least with mind) type Alt-h over the history command and this will bring up the help for built-ins.

Thank you for reporting, I will look into this and try to fix it.


Have tried one:

But unfortunately does not make nice linebreaks for longer command lines

doesn’t really seem to be a bug, more a function of zsh
See accepted answer:

1 Like

I might be lost as lost as Alice here, but wouldn’t enlarging HISTSIZE and SAVEHIST from current values of 1000 and 500, to something like 10000, be kind of a solution to this?

I try to implement that and ask @Chrysostomus if He agree it

have done your suggested changes, but I think they need some testing

1 Like

Can tested here:

$ git clone -b 0.20 https://gitlab.manjaro.org/packages/community/manjaro-zsh-config.git

$ cd manjaro-zsh-config

$ makepkg -si
1 Like

Thank you, already testing it. But my .zhistory it’s at 600 entries yet, so it may take a while…

Okay, approval and push to master needs to be done by @Chrysostomus anyway.

So we will see…

In unstable

1 Like