mirror of
https://github.com/zdharma-continuum/history-search-multi-word
synced 2024-12-01 07:39:10 +00:00
118 lines
4.4 KiB
Markdown
118 lines
4.4 KiB
Markdown
## Introduction
|
||
|
||
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
|
||
all of them will be found. The entries are syntax highlighted.
|
||
|
||
Video – view on [asciinema](https://asciinema.org/a/88954). You can resize the video by pressing `Ctrl-+` or `Cmd-+`.
|
||
|
||
[![asciicast](https://asciinema.org/a/88954.png)](https://asciinema.org/a/88954)
|
||
|
||
## News
|
||
|
||
* 11-10-2016
|
||
- Syntax highlighting of history – adapted, fine crafted, **small** part of [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting)
|
||
to color what `hsmw` shows:
|
||
|
||
![syntax highlighting](http://imagizer.imageshack.us/a/img921/1503/bMAF59.gif)
|
||
|
||
* 20-09-2016
|
||
- Keys Page Up and Page Down work and page-wise move along history. Also, `Ctrl-P`, `Ctrl-N`
|
||
move to previous and next entries
|
||
|
||
* 19-09-2016
|
||
- Better immunity to [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)
|
||
and [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) – home,
|
||
end, left and right cursor keys now work smoothly
|
||
|
||
* 25-05-2016
|
||
- Cooperation with
|
||
[zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)
|
||
plugin
|
||
- Configuration option to set page size, example use:
|
||
|
||
```zsh
|
||
zstyle ":history-search-multi-word" page-size "5"
|
||
```
|
||
|
||
## Installation
|
||
|
||
**The plugin is "standalone"**, which means that only sourcing it is needed. So to
|
||
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`).
|
||
|
||
|
||
### [Zplugin](https://github.com/psprint/zplugin)
|
||
|
||
Add `zplugin load psprint/history-search-multi-word` to your `.zshrc` file.
|
||
Zplugin will handle cloning the plugin for you automatically the next time you
|
||
start zsh.
|
||
|
||
### Antigen
|
||
|
||
Add `antigen bundle psprint/history-search-multi-word` to your `.zshrc` file.
|
||
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
|
||
psprint/history-search-multi-word` for testing before adding it to your
|
||
`.zshrc`.
|
||
|
||
### Oh-My-Zsh
|
||
|
||
1. `cd ~/.oh-my-zsh/custom/plugins`
|
||
2. `git clone git@github.com:psprint/history-search-multi-word.git`
|
||
3. Add `history-search-multi-word` to your plugin list
|
||
|
||
### Zgen
|
||
|
||
Add `zgen load psprint/history-search-multi-word` to your .zshrc file in the same
|
||
place you're doing your other `zgen load` calls in.
|
||
|
||
## Customizing
|
||
|
||
### Zstyles
|
||
|
||
```zsh
|
||
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
|
||
zstyle ":plugin:history-search-multi-word" synhl "yes" # Whether to perform syntax highlighting
|
||
```
|
||
|
||
### Syntax highlighting
|
||
|
||
Syntax highlighting is customized via `HSMW_HIGHLIGHT_STYLES` associative array.
|
||
It has keys like `reserved-word`, `alias`, `command`, `path`, which are assigned
|
||
with strings like `fg=blue,bold`, to configure how given elements are to be
|
||
colored. If you assign this array before loading `hsmw` you will change the defaults. Complete list
|
||
of available keys is [at the beginning](https://github.com/psprint/history-search-multi-word/blob/master/hsmw-highlight#L34-L62)
|
||
of `hsmw-highlight` file. Example `~/.zshrc` addition that sets `path` key –
|
||
paths that exist will be highlighted with background magenta, foreground white, bold:
|
||
|
||
```zsh
|
||
typeset -gA HSMW_HIGHLIGHT_STYLES
|
||
HSMW_HIGHLIGHT_STYLES[path]="bg=magenta,fg=white,bold"
|
||
```
|
||
|
||
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"
|
||
```
|
||
|
||
## IRC Channel
|
||
|
||
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)
|