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

How to achieve this but only with the start of the string? #116

Closed
ghost opened this issue Oct 18, 2020 · 6 comments
Closed

How to achieve this but only with the start of the string? #116

ghost opened this issue Oct 18, 2020 · 6 comments

Comments

@ghost
Copy link

ghost commented Oct 18, 2020

if I type py and press up arrow I want to match python code.py but not vim code.py

In this substring search, vim code.py obviously matches because py is a substring of vim code.py

I would like a simpler, start-only matcher.

Where does that exist?

@guidovansteen
Copy link
Member

"up-line-or-beginning-search" and "down-line-or-beginning-search" are probably the widgets you are looking for. You can "bindkey" them in the same way as "history-substring-search-up" and "history-substring-search-down"

@ghost
Copy link
Author

ghost commented Nov 1, 2020

@guidovansteen thanks for the pointer, helping me out even though I know it's not really related to this repository.

It seems that up-line-or-beginning-search and co. actually only match the very first word on the line, up to the first non-escaped space.

so

dotnet build
dotnet bin/Debug/netcoreapp2.2/MyProg.dll
dotnet build
dotnet bin<UP ARROW>

actually fills in dotnet build instead of dotnet bin/Debug/netcoreapp2.2/MyProg.dll.

@goduck777
Copy link

goduck777 commented Jan 8, 2021

You can simple remove the first star in the matching string, like this

local search_pattern="${(j:*:)_history_substring_search_query_parts[@]//(#m)[\][()|\\*?#<>~^]/\\$MATCH}*"

@h0adp0re
Copy link

This was also requested in #95 and #112, both of which also have accompanying PRs – #96 and #115, respectively.

Any thoughts from the maintainers? Seems to be a popular request. I had the same expectation after I found this plugin as I was migrating from oh-my-zsh.

@sunaku
Copy link
Member

sunaku commented Aug 3, 2021

Those PRs have been merged as of commit 4abed97. Please set the following configuration variable to enable this feature:

HISTORY_SUBSTRING_SEARCH_PREFIXED=1

@sunaku sunaku closed this as completed Aug 3, 2021
@jabuxas
Copy link

jabuxas commented Aug 20, 2024

@guidovansteen thanks for the pointer, helping me out even though I know it's not really related to this repository.

It seems that up-line-or-beginning-search and co. actually only match the very first word on the line, up to the first non-escaped space.

so

dotnet build
dotnet bin/Debug/netcoreapp2.2/MyProg.dll
dotnet build
dotnet bin<UP ARROW>

actually fills in dotnet build instead of dotnet bin/Debug/netcoreapp2.2/MyProg.dll.

i'm rewriting my zsh config without omz and i'm running into this.
even though i've set:

bindkey '^[[A' history-search-backward
bindkey '^[[B' history-search-forward

history-search-backward is only matching results that have the first command the same.
so, with this history

ls /etc/
ls /usr/
ls /e<UP ARROW>

it changes to ls /usr, and not the ls /etc/ i would expect.

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

5 participants