zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
30.95k stars 1.86k forks source link

Using without oh-my-zsh #571

Closed bushblade closed 3 years ago

bushblade commented 3 years ago

So I've been using zsh-autosuggestions happily for a while now but tried removing oh-my-zsh as I'm not really using it much (only a couple of plugins). But I can't seem to get zsh-autosuggestions to work without having oh-my-zsh also running which seems really odd to me. I installed zsh-autosuggestions through pacman on Manjaro and have not installed it using oh-my-zsh. To make it a little clearer here is my .zshrc before disabling oh-my-zsh

# Path to your oh-my-zsh installation.
export ZSH=/home/will/.oh-my-zsh

# oh-my-zsh-plugins
plugins=(git tmux gatsby)

source $ZSH/oh-my-zsh.sh
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

alias r="ranger"
alias x="exit"
alias nv="nvim"
alias rm="rm -i"
alias mv="mv -i"
alias zshconfig='nvim ~/.zshrc'
alias cl='clear'
alias ignorenode='attr -s com.dropbox.ignored -V 1 node_modules'

# powelevel10k theme
source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
VISUAL=nvim; export VISUAL EDITOR=nvim; export EDITOR

# vi mode
bindkey -v

# bind jj to normal mode 
bindkey jj vi-cmd-mode

# ssh aliases
if [ -r ~/Dropbox/.ssh.zsh ]; then
    source ~/Dropbox/.ssh.zsh
fi
export PATH="$HOME/.deno/bin:$PATH"

And with that config zsh-autosuggestions works as expected. But if I comment out my oh-my-zsh stuff...

# Path to your oh-my-zsh installation.
# export ZSH=/home/will/.oh-my-zsh

# oh-my-zsh-plugins
# plugins=(git tmux gatsby)

# source $ZSH/oh-my-zsh.sh
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh

alias r="ranger"
alias x="exit"
alias nv="nvim"
alias rm="rm -i"
alias mv="mv -i"
alias zshconfig='nvim ~/.zshrc'
alias cl='clear'
alias ignorenode='attr -s com.dropbox.ignored -V 1 node_modules'

# powelevel10k theme
source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
VISUAL=nvim; export VISUAL EDITOR=nvim; export EDITOR

# vi mode
bindkey -v

# bind jj to normal mode 
bindkey jj vi-cmd-mode

# ssh aliases
if [ -r ~/Dropbox/.ssh.zsh ]; then
    source ~/Dropbox/.ssh.zsh
fi
export PATH="$HOME/.deno/bin:$PATH"

Then zsh-autosuggestions no longer works. The path to my installation is correct, I can't work out why this could be.

Expected behavior

Should work without oh-my-zsh

Desktop

Manjaro linux zsh 5.8 (x86_64-pc-linux-gnu) Installed via pacman

romkatv commented 3 years ago

zsh-autosuggestions displays suggestions based on command history. When you disable Oh My Zsh, you also disable history. Press Up to confirm. Once you fix history, zsh-autosuggestions will work.

bushblade commented 3 years ago

Thanks for the reply, I had not realised oh-my-zsh was setting my history. Adding

SAVEHIST=1000
HISTFILE=~/.zsh_history

to my .zhshrc does fix it.