Commit graph

46 commits

Author SHA1 Message Date
Eric Nielsen
4ee70abb6f Don't overwrite config with default values
otherwise users are obliged to set the config values *after* sourcing
the plugin. They're not able to do it before. Also, re-sourcing the
plugin will reset the values to the defaults again.

A similar change was done in zsh-autosuggestions in the past:
9e4d3c3
2021-08-02 15:23:57 -05:00
Xue Qianming
4f2f17cc46
add HISTORY_SUBSTRING_SEARCH_PREFIX (#112,#115)
* `HISTORY_SUBSTRING_SEARCH_PREFIX` is a global variable that defines
  how the command history will be searched for your query. If set to a non-empty
  value, only history prefixed by your query will be matched. For example,
  if this variable is empty, `ls` will match `ls -l` and `echo ls`; if it is
  non-empty, `ls` will only match `ls -l`.

Co-authored-by: Xue Qianming <qianmingxue@microsoft.com>
2021-08-02 10:20:14 -07:00
Suraj N. Kurapati
2c36e4dd3a
Merge pull request #98 from FranciscoBorges/master
Declare `query_part` as local to avoid warnings due to `WARN_CREATE_GLOBAL`
2019-05-12 17:18:38 -07:00
d10n
19cb0eb8be Quote variable to highlight right words on zsh 4.3
When the variable is not quoted, there seems to be some difference in
evaluating the line between zsh 4.3 and 5.6
2018-12-26 19:43:49 -05:00
d10n
36505c46c7 Explicitly disable word splitting when not fuzzy
This prevents shell configuration from breaking fuzzy search
configuration
2018-12-26 19:42:36 -05:00
Francisco Borges
8d4a409c89
Declare query_part as local to avoid warnings due to WARN_CREATE_GLOBAL 2018-12-11 10:21:28 +01:00
Geza Lore
be0fe1fca9 Clean up global variable declarations
- Remove duplicate declarations
- Separate internal variables from configuration variables
2017-05-16 20:07:06 +01:00
Bengt Brodersen
fd27842cad feat: add fuzzy search 2017-05-16 19:49:29 +01:00
Geza Lore
07011f632b Fix breakage with setopt ERR_RETURN (Issue #60) 2017-05-05 19:20:48 +01:00
Suraj N. Kurapati
aae3388491 Merge pull request #62 from alyssais/declare
declare global variables to support `setopt warn_create_global`
2016-12-11 11:44:51 -08:00
disarmer mk
1a9b72a95f typeset for variables. Fixes #65 2016-12-02 22:18:19 +03:00
Alyssa Ross
fd331b8345 global variables: fix array declarations 2016-11-02 01:33:44 +00:00
Alyssa Ross
f7c8d3157b global variables: declare up-front 2016-11-02 01:23:59 +00:00
Alyssa Ross
3fa98998c5 Revert "Declare global variables"
This reverts commit b554feb7ba.
2016-11-02 01:23:59 +00:00
Alyssa Ross
d26aaa6594 Revert "Declare more global variables"
This reverts commit ec88096611.
2016-11-02 01:23:59 +00:00
Alyssa Ross
ec88096611 Declare more global variables 2016-09-13 22:00:53 +01:00
Alyssa Ross
b554feb7ba Declare global variables
This was causing warnings with `setopt warn_create_global`.
2016-08-31 16:55:09 +00:00
Suraj N. Kurapati
6008552895 GH-44: fix "parameter not set" warning by set -u
$ zsh -f
zsh% set -u
zsh% source zsh-history-substring-search.zsh
zsh% bindkey '^[[A' history-substring-search-up
zsh% bindkey '^[[B' history-substring-search-down
zsh% so<up>
_history-substring-search-begin:11: _history_substring_search_result: parameter not set
2016-07-16 09:25:50 -07:00
Geza Lore
3e64e0e9fa Fix repeat search with HIST_FIND_NO_DUPS. 2016-05-23 21:42:08 +01:00
Geza Lore
b546105d7e Initialize option to empty string instead of unsetting. 2016-05-22 09:41:30 +01:00
Geza Lore
8224802bda Use lazy enumeration to keep response time fast.
With HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE, it can take a while to compute
all unique search results, which would normally keep the shell unresponsive
during this computation.

This commit separates the retrieval of all history matches from the
computation of the matches that need to be presented to the user (unique
matches only if HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set). The
computation of the matches needing to be displayed is then done lazily,
and only when the user requests a new previously undisplayed result.
This keeps the response time fast while still enabling us to filter for
unique search results.
2016-03-06 10:50:33 +00:00
Geza Lore
352943873d Add option to ensure unique search results.
If HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE is set to a non-empty string,
then all displayed search results will be unique even if the shell
option HIST_IGNORE_ALL_DUPS is not set.
2016-03-05 19:36:25 +00:00
Geza Lore
7444ca5783 Do not search history when query is empty.
We used to do a history search when the query string was empty, which
resulted in all history indices being returned, but they are never
actually used as _history-substring-search-up-history and
_history-substring-search-down-history will just act like ZSH up-history
and down-history if the query is empty. Removing this unnecessary lookup
should speed up the empty query case, especially if you have a long
history.
2016-03-05 15:21:24 +00:00
Geza Lore
6001e1f0f5 Refactor to reverse internal enumeration order.
This is a pure refactoring patch and does note change any functionality.

We remove an unnecessary reversal of the history match array by swapping
the enumeration order of match indices. Older entries now have higher
internal indices than younger entries, and hence we start from 1.

Also removed one unreachable elif clause each from search-up and
search-down.
2016-03-05 13:53:25 +00:00
Matt Hamilton
e2ab5b8214 convert ksh functions to POSIX syntax 2015-09-28 13:19:16 -04:00
Suraj N. Kurapati
6d7bc718ae skip HIST_FIND_NO_DUPS if HIST_IGNORE_ALL_DUPS set
Thanks to @ELLIOTTCABLE for suggesting this optimization:
https://github.com/zsh-users/zsh-history-substring-search/issues/19#issuecomment-90295460
2015-04-06 17:33:27 -07:00
Suraj N. Kurapati
fc7eb3cbf0 GH-42: speed up HIST_FIND_NO_DUPS: drop O(n) prune
Don't prune all duplicates from the search space *before* performing the
search! Instead, simply redo the search when a duplicate result is found.
2015-03-22 11:16:12 -07:00
Parker Coates
13033d87a1 GH-19: Respect the HIST_FIND_NO_DUPS option.
This is the best way I've found to remove duplicate entries while
keeping the most recent occurence, but I'm not a ZSH expert. There may
be a more efficient way.
2015-03-16 08:35:28 -03:00
Parker Coates
fd31074470 Use array reversal instead of array sorting.
There's no need to do a full numerical sort here, since we know the
keys will be in reverse numerical order, because (R) searches in last-
to-first order. Not a big deal, but this is just simpler and
presumably more efficient.

Also cleaned up a rather confusing comment about (on) being used to
remove duplicates, which it definitely doesn't.
2015-03-16 08:30:05 -03:00
Suraj N. Kurapati
3c7b079275 Merge zsh-syntax-highlighting #143 to close #15
The problem reported in issue #15 was fixed upstream in #143:
https://github.com/zsh-users/zsh-syntax-highlighting/pull/143
2015-02-17 12:16:55 -08:00
Suraj N. Kurapati
82fbef5132 drop default key bindings (move them into README)
https://github.com/sorin-ionescu/prezto/issues/422

3c5363ef9b
2013-04-25 14:46:22 -07:00
Suraj N. Kurapati
3bd84be43e we need to bind ^[[A and ^[[B not ^[A and ^[B 2013-02-22 12:21:34 -08:00
Sorin Ionescu
ebde030990 GH-12: fix arrow bindkey and support emacs & vicmd 2012-11-21 22:11:32 -08:00
Suraj N. Kurapati
04c2eca00c use explicit return codes instead of true & false 2012-03-28 11:00:53 -07:00
Sorin Ionescu
c61c9956c4 use 0 instead of true in returns 2012-03-28 11:05:00 -04:00
Suraj N. Kurapati
a23cfbb11f GH-10: retain not-found highlight at boundaries 2012-03-28 06:44:05 -07:00
Suraj N. Kurapati
226ae9a368 GH-10: clear highlights before displaying result 2012-03-27 21:36:09 -07:00
Suraj N. Kurapati
527f95fee9 GH-9: retain search query highlight on cursor move 2012-03-13 13:54:54 -07:00
Suraj N. Kurapati
0943070a9d GH-8: do not interfere with self-insert overrides 2012-03-12 21:23:37 -07:00
Aaron Hall
68904e1d72 Update widget-remap code from zsh-syntax-highlighting
This brings in the several improvements since the code was initially
added for compatibility. In particular, this fixes widget conflicts with
existing functions and executables by prefixing all redefined widgets
with "_zsh_highlight_widget_".
2012-01-11 21:43:27 -08:00
Suraj N. Kurapati
ba2e1a76aa extendedglob used in *end() function; closes #6 2011-09-30 17:02:29 -07:00
Suraj N. Kurapati
c5c4ab8eea change options locally and restore them on return 2011-09-22 11:16:34 -07:00
Sorin Ionescu
8870c7e279 fix #2: always use up/down-line-or-history 2011-09-17 14:07:31 -04:00
Suraj N. Kurapati
1ec51023d7 move project description into README & markdownify 2011-08-04 14:19:56 -07:00
Suraj N. Kurapati
981b787ca0 separate markdown URL list into references section 2011-07-25 13:42:21 -07:00
Colin Hebert
dfc7ac9d06 add "zsh-" prefix to history-substring-search
@zsh-users/zsh-syntax-highlighting and
@zsh-users/zsh-history-substring-search don't follow the same naming
convention.

This commit just rename history-substring-search.zsh and
history-substring-search.plugin.zsh to zsh-history-substring-search.zsh
and zsh-history-substring-search.plugin.zsh respectively.
2011-07-25 13:39:39 -07:00
Renamed from history-substring-search.zsh (Browse further)