zsh-users / zsh-history-substring-search

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

Need Help, i must "source .zshrc" first for the plugin to works #140

Closed rafli-sss closed 1 year ago

rafli-sss commented 1 year ago

Screenshot from 2022-12-11 12-06-17

At first, ".zsh" + Up Arrow should be "nvim .zshrc" or "source .zshrc". But nothing happens, Then i "source .zshrc". And it works.

rafli-sss commented 1 year ago

Closed

It is because of zsh-vi-mode plugin. I have to bindkey in zvm_after_init_commands

vcolano commented 11 months ago

@rafli-sss thanks a ton for your last comment, this was my issue! I am using oh-my-zsh, here is the relevant part of my .zshrc file after I got it working:

# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(
    git
    docker
    zsh-vi-mode
    zsh-autosuggestions
    zsh-syntax-highlighting
    zsh-history-substring-search
)

# Configure zsh-history-substring search to work with zsh-vi-mode
# See https://github.com/zsh-users/zsh-history-substring-search#usage
# and https://unix.stackexchange.com/a/248789
# and https://github.com/jeffreytse/zsh-vi-mode#execute-extra-commands
zvm_after_init_commands+=("bindkey '^[[A' history-substring-search-up && bindkey '^[[B' history-substring-search-down")

# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
alias brew=/opt/bin/brew

# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh

source $ZSH/oh-my-zsh.sh