2017-02-15 07:48:06 +00:00
[![License (GPL version 3) ](https://img.shields.io/badge/license-GNU%20GPL%20version%203-blue.svg?style=flat-square )](./LICENSE)
[![MIT License ](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square )](./LICENSE)
![ZSH 5.0.0 ](https://img.shields.io/badge/zsh-v5.0.0-orange.svg?style=flat-square )
2018-08-28 08:12:38 +00:00
[![paypal ](https://img.shields.io/badge/-Donate-yellow.svg?longCache=true&style=for-the-badge )](https://www.paypal.me/ZdharmaInitiative)
[![patreon ](https://img.shields.io/badge/-Patreon-orange.svg?longCache=true&style=for-the-badge )](https://www.patreon.com/psprint)
< br / > You can request a feature when donating, even fancy or advanced ones get implemented this way. [There are
reports](DONATIONS.md) about what is being done with the money received.
2017-05-23 16:47:16 +00:00
2016-10-25 18:16:44 +00:00
# Introduction
2016-05-22 06:58:00 +00:00
Binds `Ctrl-R` to a widget that searches for multiple keywords in `AND` fashion.
In other words, you can enter multiple words, and history entries that match
2016-10-15 06:24:50 +00:00
all of them will be found. The entries are syntax highlighted.
2016-05-22 06:58:00 +00:00
2016-10-12 15:26:49 +00:00
Video – view on [asciinema ](https://asciinema.org/a/88954 ). You can resize the video by pressing `Ctrl-+` or `Cmd-+` .
2016-05-22 06:58:00 +00:00
2016-10-12 15:26:49 +00:00
[![asciicast ](https://asciinema.org/a/88954.png )](https://asciinema.org/a/88954)
2016-05-22 07:07:34 +00:00
2018-01-05 15:20:34 +00:00
HSMW has feature called **context viewing** – see all occurrences of a command together
with surrounding commands:
2016-10-16 17:09:00 +00:00
2018-01-05 15:20:34 +00:00
[![asciicast ](https://asciinema.org/a/155704.png )](https://asciinema.org/a/155704)
2016-10-16 17:09:00 +00:00
2018-08-04 15:33:04 +00:00
Set:
```zsh
zstyle :plugin:history-search-multi-word reset-prompt-protect 1
```
2019-04-20 19:02:08 +00:00
to be able to use `zle reset-prompt` in your e.g. `sched` calls, in presence of
`zdharma/fast-syntax-highlighting` , `zsh-users/zsh-syntax-highlighting` ,
`zsh-users/zsh-autosuggestions` and other plugins that hook up into Zshell by
overloading Zle widgets. You could e.g. use `sched` in following way:
```zsh
PROMPT=%B%F{yellow}%D{%H:%M:%S}%B%b%f
schedprompt() {
zle & & zle reset-prompt
sched +1 schedprompt
}
zmodload -i zsh/sched
schedprompt
```
to refresh the clock in prompt every second. The `reset-prompt-protect` zstyle
needs to be set to 1 for correct cooperation with HSMW. Or, you could use `zle
.reset-prompt` (i.e. with the dot in front) to call the original, not
overloaded (by F-Sy-H, zsh-autosuggestsions, etc.) `reset-prompt` widget.
2018-08-04 15:33:04 +00:00
2016-10-25 18:16:44 +00:00
# News
2018-05-25 15:18:31 +00:00
* 25-05-2018
- Hash holding paths that shouldn't be grepped (globbed) – blacklist for slow disks, mounts, etc.:
```zsh
typeset -gA FAST_BLIST_PATTERNS
FAST_BLIST_PATTERNS[/mount/nfs1/*]=1
FAST_BLIST_PATTERNS[/mount/disk2/*]=1
```
2016-10-27 14:40:13 +00:00
2017-06-13 05:23:59 +00:00
* 13-06-2017
- Canceling search doesn't clear entered query. Change to previous behavior via:
```zsh
zstyle ":plugin:history-search-multi-word" clear-on-cancel "yes"
```
2017-04-12 07:13:31 +00:00
* 12-04-2017
- Page size can be relative to screen height, e.g.:
```zsh
zstyle ":history-search-multi-word" page-size "LINES/4"
```
2017-04-05 08:14:43 +00:00
* 05-04-2017
- 17% performance optimization
2017-01-27 12:08:52 +00:00
* 27-01-2017
- Input-driven case-sensivity of search – if your query contains capital latin letters, search will be case-sensitive
2016-11-12 15:40:37 +00:00
* 12-11-2016
- HSMW can now show context of selected history entry! Just hit `Ctrl-K` , [video ](https://asciinema.org/a/92516 )
- More performance optimizations
2016-10-31 13:56:28 +00:00
* 31-10-2016
2016-11-05 07:03:58 +00:00
- Newlines do not disturb the parser anymore, and are also highlighted with a dark color – [video ](https://asciinema.org/a/91159 )
2016-10-31 13:56:28 +00:00
2016-10-27 14:39:15 +00:00
* 27-10-2016
- New optimizations – **30%** speed up of syntax highlighting!
2016-10-27 14:40:13 +00:00
- Architectural change – syntax highlighting is now computed rarely, so any possible performance problems are now solved, in advance!
2016-10-27 14:39:15 +00:00
2016-10-24 08:04:01 +00:00
* 24-10-2016
2016-10-24 08:08:55 +00:00
- Workaround for Zsh versions like 5.0.2 has been added – **Ctrl-V** and **ESC** cancel search. On such Zsh
2016-10-24 08:04:01 +00:00
versions Ctrl-C might not work. Fully problem-free Zsh version will be the upcoming 5.3, where
I have together with Zsh Hackers fully fixed the Ctrl-C issue.
2016-10-22 09:59:58 +00:00
* 22-10-2016
- Search process has been optimized by 20%! History sizes like 100000 are now supported.
- Active history entry can be `underline` , `standout` (i.e. inverse video), `bold` , `bg=blue` , etc. with
2016-10-22 10:53:27 +00:00
the new Zstyle `:plugin:history-search-multi-word / active` (see Zstyles section) – [video ](https://asciinema.org/a/90214 ).
2016-10-22 09:59:58 +00:00
2016-10-16 17:09:00 +00:00
* 16-10-2016
2016-10-22 10:01:03 +00:00
- More optimizations of syntax highlighting (40% in total for the two days) – new video above.
2016-10-16 17:09:00 +00:00
2016-10-15 12:46:44 +00:00
* 15-10-2016
- The compact, already optimized (by me) [zsh-syntax-highlighting ](https://github.com/zsh-users/zsh-syntax-highlighting ) part has been further optimized by 21%!
Also, more tokens are highlighted – variable expressions like `"${(@)var[1,3]}"` (when quoted).
2016-05-25 06:05:24 +00:00
2016-10-11 07:28:05 +00:00
* 11-10-2016
2016-10-15 06:24:50 +00:00
- Syntax highlighting of history – adapted, fine crafted, **small** part of [zsh-syntax-highlighting ](https://github.com/zsh-users/zsh-syntax-highlighting )
2016-10-11 07:28:05 +00:00
to color what `hsmw` shows:
![syntax highlighting ](http://imagizer.imageshack.us/a/img921/1503/bMAF59.gif )
2016-09-20 06:46:46 +00:00
* 20-09-2016
2016-09-20 07:07:48 +00:00
- Keys Page Up and Page Down work and page-wise move along history. Also, `Ctrl-P` , `Ctrl-N`
2016-10-22 09:59:58 +00:00
move to previous and next entries.
2016-09-20 06:46:46 +00:00
2016-09-19 14:22:17 +00:00
* 19-09-2016
2016-09-20 06:46:46 +00:00
- Better immunity to [zsh-autosuggestions ](https://github.com/zsh-users/zsh-autosuggestions )
2016-09-19 14:42:44 +00:00
and [zsh-syntax-highlighting ](https://github.com/zsh-users/zsh-syntax-highlighting ) – home,
2016-10-22 09:59:58 +00:00
end, left and right cursor keys now work smoothly.
2016-09-19 14:22:17 +00:00
2016-05-25 06:05:24 +00:00
* 25-05-2016
- Cooperation with
[zsh-autosuggestions ](https://github.com/zsh-users/zsh-autosuggestions )
plugin
2016-05-25 07:24:03 +00:00
- Configuration option to set page size, example use:
```zsh
zstyle ":history-search-multi-word" page-size "5"
```
2016-05-25 06:05:24 +00:00
2016-10-25 18:16:44 +00:00
# Installation
2016-05-22 07:07:34 +00:00
2016-09-13 16:00:18 +00:00
**The plugin is "standalone"**, which means that only sourcing it is needed. So to
2016-06-09 07:24:27 +00:00
install, unpack `history-search-multi-word` somewhere and add
```zsh
source {where-hsmw-is}/history-search-multi-word.plugin.zsh
```
to `zshrc` .
If using a plugin manager, then `Zplugin` is recommended, but you can use any
other too, and also install with `Oh My Zsh` (by copying directory to
`~/.oh-my-zsh/custom/plugins` ).
2018-04-29 15:39:50 +00:00
### [Zplugin](https://github.com/zdharma/zplugin)
2016-05-23 15:58:20 +00:00
2018-04-29 15:39:50 +00:00
Add `zplugin load zdharma/history-search-multi-word` to your `.zshrc` file.
2016-05-23 15:58:20 +00:00
Zplugin will handle cloning the plugin for you automatically the next time you
start zsh.
2016-06-09 07:26:17 +00:00
### Antigen
2016-05-22 07:07:34 +00:00
2018-04-29 15:39:50 +00:00
Add `antigen bundle zdharma/history-search-multi-word` to your `.zshrc` file.
2016-05-23 15:58:20 +00:00
Antigen will handle cloning the plugin for you automatically the next time you
start zsh. You can also add the plugin to a running zsh with `antigen bundle
2018-04-29 15:39:50 +00:00
zdharma/history-search-multi-word` for testing before adding it to your
2016-05-23 15:58:20 +00:00
`.zshrc` .
2016-05-22 18:58:11 +00:00
2016-06-09 07:26:17 +00:00
### Oh-My-Zsh
2016-05-22 18:58:11 +00:00
1. `cd ~/.oh-my-zsh/custom/plugins`
2018-04-29 15:39:50 +00:00
2. `git clone git@github.com:zdharma/history-search-multi-word.git`
2016-09-13 16:00:18 +00:00
3. Add `history-search-multi-word` to your plugin list
2016-05-22 18:58:11 +00:00
2016-06-09 07:26:17 +00:00
### Zgen
2016-05-22 18:58:11 +00:00
2018-04-29 15:39:50 +00:00
Add `zgen load zdharma/history-search-multi-word` to your .zshrc file in the same
2016-09-13 16:00:18 +00:00
place you're doing your other `zgen load` calls in.
2016-05-22 18:58:11 +00:00
2018-08-03 07:22:19 +00:00
### Arch Linux
1. Install [`zsh-history-search-multi-word-git` ](https://aur.archlinux.org/packages/zsh-history-search-multi-word-git/ ) from the [AUR ](https://wiki.archlinux.org/index.php/Arch_User_Repository ).
2. Add the following to your `.zshrc` :
```sh
source /usr/share/zsh/plugins/history-search-multi-word/history-search-multi-word.plugin.zsh
```
3. Start a new terminal session
2016-10-25 18:16:44 +00:00
# Customizing
2016-05-22 19:27:39 +00:00
2016-10-25 18:16:44 +00:00
## Zstyles
2016-05-22 19:27:39 +00:00
2016-05-22 07:07:34 +00:00
```zsh
Zstyle to configure whether to check paths for existence
parse.zsh -oo, after changes:
Running time: 1.5653990000
num calls time self name
-----------------------------------------------------------------------------------
1) 350 1557,37 4,45 99,99% 1199,04 3,43 76,98% -hsmw-highlight-process
2) 2800 294,91 0,11 18,93% 294,91 0,11 18,93% -hsmw-highlight-string
3) 1750 40,81 0,02 2,62% 40,81 0,02 2,62% -hsmw-highlight-check-path
4) 1400 22,61 0,02 1,45% 22,61 0,02 1,45% -hsmw-highlight-main-type
5) 1 0,12 0,12 0,01% 0,12 0,12 0,01% -hsmw-highlight-fill-option-variables
6) 1 0,02 0,02 0,00% 0,02 0,02 0,00% -hsmw-highlight-init
2016-11-05 10:36:03 +00:00
zstyle ":history-search-multi-word" page-size "8" # Number of entries to show (default is $LINES/3)
zstyle ":history-search-multi-word" highlight-color "fg=yellow,bold" # Color in which to highlight matched, searched text (default bg=17 on 256-color terminals)
zstyle ":plugin:history-search-multi-word" synhl "yes" # Whether to perform syntax highlighting (default true)
zstyle ":plugin:history-search-multi-word" active "underline" # Effect on active history entry. Try: standout, bold, bg=blue (default underline)
zstyle ":plugin:history-search-multi-word" check-paths "yes" # Whether to check paths for existence and mark with magenta (default true)
2017-06-13 05:23:59 +00:00
zstyle ":plugin:history-search-multi-word" clear-on-cancel "no" # Whether pressing Ctrl-C or ESC should clear entered query
2016-05-22 07:07:34 +00:00
```
2016-10-25 18:16:44 +00:00
## Syntax highlighting
2016-10-12 14:23:42 +00:00
Syntax highlighting is customized via `HSMW_HIGHLIGHT_STYLES` associative array.
2018-01-05 15:24:46 +00:00
It has keys like `reserved-word` , `alias` , `command` , `path` , etc. which are assigned
2016-10-12 14:23:42 +00:00
with strings like `fg=blue,bold` , to configure how given elements are to be
2018-01-05 15:24:46 +00:00
colored. If you assign this array before or after loading `hsmw` you will change the defaults. Complete list
2018-04-29 15:39:50 +00:00
of available keys is [at the beginning ](https://github.com/zdharma/history-search-multi-word/blob/master/hsmw-highlight#L34-L62 )
2016-10-12 14:30:44 +00:00
of `hsmw-highlight` file. Example `~/.zshrc` addition that sets `path` key –
2016-10-12 15:46:55 +00:00
paths that exist will be highlighted with background magenta, foreground white, bold:
2016-10-12 14:30:44 +00:00
```zsh
typeset -gA HSMW_HIGHLIGHT_STYLES
HSMW_HIGHLIGHT_STYLES[path]="bg=magenta,fg=white,bold"
```
2016-10-12 14:23:42 +00:00
2016-10-13 06:46:09 +00:00
Following code will enable coloring of options of form "-o" and "--option", with cyan:
```zsh
typeset -gA HSMW_HIGHLIGHT_STYLES
HSMW_HIGHLIGHT_STYLES[single-hyphen-option]="fg=cyan"
HSMW_HIGHLIGHT_STYLES[double-hyphen-option]="fg=cyan"
```
2016-10-22 11:22:02 +00:00
Following code will use 256 colors to highlight command separators (like ";" or "& & "):
```zsh
HSMW_HIGHLIGHT_STYLES[commandseparator]="fg=241,bg=17"
```
2016-10-25 18:16:44 +00:00
# IRC Channel
2016-05-22 07:33:27 +00:00
Channel `#zplugin@freenode` is a support place for all author's projects. Connect to:
[chat.freenode.net:6697 ](ircs://chat.freenode.net:6697/%23zplugin ) (SSL) or [chat.freenode.net:6667 ](irc://chat.freenode.net:6667/%23zplugin )
and join #zplugin .
Following is a quick access via Webchat [![IRC ](https://kiwiirc.com/buttons/chat.freenode.net/zplugin.png )](https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin)