Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work with zinit #110

Open
quasipedia opened this issue Apr 24, 2020 · 11 comments
Open

Does not work with zinit #110

quasipedia opened this issue Apr 24, 2020 · 11 comments

Comments

@quasipedia
Copy link

Describe the bug

Upon fresh installation and configuration of zinit and all the rest, the plugin does not work, and throw a no such file or directory error. This is the actual output (OMZ:: is just the zinit syntax to consume oh-my-zsh plugins). Other plugins (7 in total) work flawlessly.

Downloading `OMZ::plugins/history-substring-search/history-substring-search.plugin.zsh' (with curl, wget, lftp)...
/home/mac/.zinit/snippets/OMZ::plugins--history-substring-search/history-substring-search.plugin.zsh/history-substring-search.plugin.zsh:source:2: no such file or directory: /home/mac/.zinit/snippets/OMZ::plugins--history-substring-search/history-substring-search.plugin.zsh/history-substring-search.zsh

The functionality of the plugin is not there (so the error is not just cosmetic: the plugin does not work).

To Reproduce

  1. Install zinit
  2. In .zshrc att the following line: zinit snippet OMZ::plugins/history-substring-search/history-substring-search.plugin.zsh, save and exit.
  3. Open a new terminal

Desktop (please complete the following information):

  • OS / Distro: Fedora 32 (64bit)
  • ZSH Version: zsh 5.8 (x86_64-redhat-linux-gnu)
  • Terminal emulator: Tilix (https://gnunn1.github.io/tilix-web/)
  • Both zinit and zsh-history-substring-search are the latest version available on GitHub
@alichtman
Copy link

alichtman commented May 5, 2020

I have it mostly working (with some minor bugs and inconsistencies) with:

$ cat ~/.zshrc
...
...

# Plugins {{{

source "$ZDOTDIR/.zinit/bin/zinit.zsh"

autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit

# oh-my-zsh plugins
zinit ice wait'!'
zinit snippet OMZ::lib/git.zsh
zinit ice wait'!'
zinit snippet OMZP::git
zinit ice wait'!'
zinit snippet OMZP::fzf
zinit ice wait'!'
zinit snippet OMZP::ssh-agent

# https://github.com/zdharma/zinit-configs/blob/a60ff64823778969ce2b66230fd8cfb1a957fe89/psprint/zshrc.zsh#L277
# Fast-syntax-highlighting & autosuggestions
zinit wait lucid for \
 atinit"ZINIT[COMPINIT_OPTS]=-C; zpcompinit; zpcdreplay" \
    zdharma/fast-syntax-highlighting \
 atload"!_zsh_autosuggest_start" \
    zsh-users/zsh-autosuggestions \
 blockf \
    zsh-users/zsh-completions

# GitHub Plugins
zinit ice wait'!'
zinit light zsh-users/zsh-history-substring-search

I have this in my ~/.zshenv:

...
# zinit
declare -A ZINIT
ZINIT[HOME_DIR]=$ZDOTDIR/.zinit
ZINIT[BIN_DIR]=$ZDOTDIR/.zinit/bin
ZINIT[PLUGINS_DIR]=$ZDOTDIR/.zinit/plugins
ZINIT[COMPLETIONS_DIR]=$ZDOTDIR/.zinit/completions
ZINIT[SNIPPETS_DIR]=$ZDOTDIR/.zinit/snippets
ZINIT[ZCOMPDUMP_PATH]=$XDG_CACHE_HOME/zcompdump
...

@bricewge
Copy link

With the PR #108 it's easier to get a configured zsh-history-substring-search working with zinit, it boils down to the following:

# Your configuration for the plugins
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#586e75'
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=#d33682,fg=#002b36,bold'
export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_NOT_FOUND='bg=#dc322f,fg=#002b36,bold'
function _history_substring_search_config() {
    bindkey '^[[A' history-substring-search-up
    bindkey '^[[B' history-substring-search-down
}

# Syntax highlighting
zinit ice wait
zinit load zsh-users/zsh-syntax-highlighting
# NOTE The order is important here since it should be loaded before zsh-history-substring-search:
# https://github.com/zsh-users/zsh-history-substring-search#usage

# History substring search
zinit ice wait atload'_history_substring_search_config' \
  ver'dont-overwrite-config'
zinit load 'ericbn/zsh-history-substring-search'
# NOTE When #108 will be merged the three previous lines will be replaced by:
# zinit load 'zsh-users/zsh-history-substring-search'
# zinit ice wait atload'_history_substring_search_config'

Note than I'm not using OMZ here tho.

@alichtman
Copy link

alichtman commented Jun 28, 2020

bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down

This isn't OS agnostic (only works on macOS for me, fails on Linux). You should use this syntax:

OS=$(uname -s)
if [ "$OS" = "Darwin" ]; then
    bindkey '^[[A' history-substring-search-up
    bindkey '^[[B' history-substring-search-down
elif [ "$OS" = "Linux" ]; then
    # https://superuser.com/a/1296543
    # key dict is defined in /etc/zsh/zshrc
    bindkey "$key[Up]" history-substring-search-up
    bindkey "$key[Down]" history-substring-search-down
fi

Edit: Updated syntax

@bricewge
Copy link

This isn't OS agnostic (only works on macOS for me, fails on Linux). You should use this syntax:

Looks like it's off-topic. The config was the more concise example I could conjure, see here and there for my actual configuration.

'^[[…' comes from the README. $key… doesn't work on my Linux system, it isn't OS agnostic at all since it's from a distro specific config not upstream zsh. If you want the widest compatible syntax, then use the terminfo module which is where the custom $key array gets it's values; this syntax is already present in the README.

@alichtman
Copy link

'^[[…' comes from the README

This was where I got the syntax for my config originally, which broke when I moved my config to Linux. Replacing these weird escape sequences with $key solved the problem. I believe I found the solution in one of the issues on this repo.

all since it's from a distro specific config not upstream zsh

The comment at the top of the file is just outdated (fixed in the last commit, thanks for pointing that out). I use this config on my Linux box daily.

And TIL that $key is an Ubuntu-specific feature of zsh and not included upstream.

I could have phrased my response better. All I meant was that if I had used $key or $terminfo, instead of hardcoding the escape sequences in, I would have had fewer issues migrating my config to different OSes. However, I'm now considering using $terminfo instead of $key for even better portability (that I thought I already had, hence my OS agnosticism comment before).

@quasipedia
Copy link
Author

OP here. Still not really getting what I should do to have the plugin working. For what matters, the ${key[Up]} style of syntax works on fedora too, but I fail to understand the link between the solutions posted here and the error message, in which it appears the issue being the file name. Any help in understanding appreciated. :)

@alichtman
Copy link

alichtman commented Jul 8, 2020

Try initializing it like I do:

# GitHub Plugins
zinit ice wait'!'
zinit light zsh-users/zsh-history-substring-search

instead of using snippet

@quasipedia
Copy link
Author

quasipedia commented Jul 9, 2020

Thank you @alichtman ! Trying to do as you said prompts me for username and password for GitHub, which is weird (why would zinit want to know them to just clone a repo?) plus I do have ssh set up (why isn't zinit using that instead?). For me it worked by remixing your example with the ver'dont-overwrite-config' and using ericbn/zsh-history-substring-search instead of zsh-users/zsh-history-substring-search as suggested in @bricewge snippet.

Now it works, but... is the fact one must use this way to load it (as opposed to use a regular "snippet" as for all things OMZ) make me feel this issue is still valid (please correct me if I am mistaken).

Thanks both for your help! :)

EDIT: The only minor annoyance is that each time a new terminal windows loads, I got the message: Loaded ericbn/zsh-history-substring-search, but I can live with that. :)

@alichtman
Copy link

ericbn/zsh-history-substring-search

I would advise against using this fork (that's currently even with this repo), and use the master repo instead.

@bricewge
Copy link

[...] I got the message: Loaded ericbn/zsh-history-substring-search, but I can live with that. :)

@quasipedia To get rid of that message just add silent at the end of the line starting with zinit ice, you can read the documentation about it.

@sunaku
Copy link
Member

sunaku commented Aug 3, 2021

Now that PR #108 is merged, can we close this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants