zsh-users / zsh-history-substring-search

🐠 ZSH port of Fish history search (up arrow)
2.61k stars 156 forks source link

Have to Source ~/.zshrc for it to function #122

Open Padswynn opened 3 years ago

Padswynn commented 3 years ago

Basically title is the problem. I have to do this everytime I load the shell interactive, and this is the only plugin that doesn't function.

I used OMF at first, and the problem started. Then I switched to Antigen, still a problem, and I even installed it via arch's repository... still nothing. Here is my .zshrc:

source $HOME/antigen.zsh

# The Order of the Plugins hasn't seemed to help
antigen bundle jeffreytse/zsh-vi-mode
antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-history-substring-search

antigen apply

# Some fun interactive stuff
[[ -o interactive ]] && echo 'This is What Space Smells Like'
[[ -o interactive ]] && (cat ~/.cache/wal/sequences &)
[[ -o interactive ]] && source ~/.cache/wal/colors-tty.sh
[[ -o interactive ]] && . ~/.cache/wal/colors.sh
# Commented out, but did not work when commented in either
# [[ -o interactive ]] && source zsh-syntax-highlighting.zsh
# [[ -o interactive ]] && source zsh-history-substring-search.zsh

# My Prompt stuff
function zvm_after_select_vi_mode() {
  case $ZVM_MODE in
    $ZVM_MODE_NORMAL)
      PROMPT='%B%F{yellow}paddy%f%b at %B%F{magenta}%m%f%b in %B%F{yellow}%~%f%b
↪ '
    ;; 
    $ZVM_MODE_INSERT)
      PROMPT='%F{yellow}%Bpaddy%f%b at %F{magenta}%B%m%f%b in %B%F{yellow}%~%f%b %B%F{blue}
↪%b%f '
    ;;
    $ZVM_MODE_VISUAL)
      PROMPT='%F{yellow}%Bpaddy%f%b at %F{magenta}%B%m%f%b in %B%F{yellow}%~%f%b
↪ '
    ;;
    $ZVM_MODE_VISUAL_LINE)
      PROMPT='%F{yellow}%Bpaddy%f%b at %F{magenta}%B%m%f%b in %B%F{yellow}%~%f%b
↪ '
    ;;
    $ZVM_MODE_REPLACE)
      PROMPT='%F{yellow}%Bpaddy%f%b at %F{magenta}%B%m%f%b in %B%F{yellow}%~%f%b
↪'
    ;;
  esac
}
ZVM_CURSOR_STYLE_ENABLED=false
HISTFILE=~/zsh/histfile
HISTSIZE=1000
SAVEHIST=5000

# neither set of bindkeys helped
bindkey "$terminfo[kcuu1]" history-substring-search-up
bindkey "$terminfo[kcud1]" history-substring-search-down
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down

path+=('/home/paddy/.local/bin', '/home/paddy/files/prog', '/home/paddy/.emacs.d/bin')
export PATH

alias foo='bar'
alias foo2='bar2'
E-ricus commented 3 years ago

I see the same thing, I have to source for it to work, it only happens to me on mac, with the exact same configuration on linux, it works as expected

E-ricus commented 3 years ago

@Padsworth https://github.com/zsh-users/zsh-history-substring-search/issues/110#issuecomment-650610951 this worked for me

Padswynn commented 3 years ago

@ericpubu Thanks a ton - no point in using antigen if it's not going to work for me right? Also zinit just seems to be so much faster. Still wish I knew why this happened, but oh well.

Matthieu-OD commented 2 years ago

Were you able to fix this error? I have the same on my mac. I tried with oh-my-zsh installation and brew installation.

notuxic commented 2 years ago

I had the same issue, where the plugin is installed through antigen and would only work after manually sourcing the .zshrc. In my case the keybinds for the arrow-keys were sneakily overwritten by a setopt EMACS, which seems to do nothing when already set, which is why it worked after sourcing the .zshrc a second time.

So if anyone else runs into this problem, run keybind to check if your keybinds are actually properly set. They may just have been overwritten by something else (maybe some config-files shipped with the installed zsh package, which would explain why the same config works on some systems but not others).

t56k commented 2 years ago

Just bind the keys at the bottom of your .zshrc. Problem solved on macOS

vcolano commented 11 months ago

If you are facing this issue and also using https://github.com/jeffreytse/zsh-vi-mode then check out https://github.com/zsh-users/zsh-history-substring-search/issues/140