zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
30.43k stars 1.85k forks source link

Not remembering history past session #645

Closed cawoodm closed 2 years ago

cawoodm commented 2 years ago

Describe the bug

Autocomplete history is not being written - I get autocompletion of commands inside my session but when I exit zsh and return, everything is forgotten.

To Reproduce

Steps to reproduce the behavior:

% zsh -df
% source path/to/zsh-autosuggestions.zsh
% ls foo
% ls # auto suggest, inserts ls foo here
% exit zsh
% zsh
% ls # Nothing is suggested

Expected behavior

I expect auto suggest to persist across sessions. I have deleted both my .bash_history and .zsh_history - permissions were rw. They are not being re-created as I use zsh.

Screenshots

Desktop

Additional context

cawoodm commented 2 years ago

.zshrc

export SHELL=$(which zsh)
export PATH=$HOME/bin:/usr/local/bin:$PATH
export ZSH="$HOME/.oh-my-zsh"

ZSH_THEME="rkj"
ZSH_CUSTOM=~/.oh-my-zsh/custom
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
source $ZSH_CUSTOM/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
#ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=8'

alias zshconfig="vi ~/.zshrc"
alias ohmyzsh="vi ~/.oh-my-zsh"
alias cls=clear
alias md=mkdir
alias ls="ls -alF --color=auto"

eval "$(starship init zsh)"

figlet zsh
guillaumeboehm commented 2 years ago

same issue with bare minimum .zshrc with only: source $HOME/.config/zsh/zsh-autosuggestions/zsh-autosuggestions.zsh

416 or #604 didn't help

ericfreese commented 2 years ago

Zsh doesn't persist history across sessions by default. Take a look here or Google around for how to configure zsh to persist history across sessions:

https://unix.stackexchange.com/questions/389881/history-isnt-preserved-in-zsh

tylerferrara commented 1 year ago

Try this!

# inside .zshrc
setopt APPEND_HISTORY
setopt SHARE_HISTORY
HISTFILE=$HOME/.zhistory
SAVEHIST=1000
HISTSIZE=999
setopt HIST_EXPIRE_DUPS_FIRST
setopt EXTENDED_HISTORY

source: https://dev.to/rossijonas/how-to-set-up-history-based-autocompletion-in-zsh-k7o