history-search-multi-word/README.md

169 lines
7.1 KiB
Markdown
Raw Normal View History

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)
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
2016-10-17 04:25:57 +00:00
HSMW is **FAST** highlighting 20 concurrent complex history entries does not cause real slow down:
2016-10-16 17:09:00 +00:00
[![asciicast](https://asciinema.org/a/89406.png)](https://asciinema.org/a/89406)
2016-10-25 18:16:44 +00:00
# News
2016-10-27 14:40:13 +00:00
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
* 19-09-2016
2016-09-20 06:46:46 +00:00
- 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,
2016-10-22 09:59:58 +00:00
end, left and right cursor keys now work smoothly.
2016-05-25 06:05:24 +00:00
* 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"
```
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`).
2016-05-23 15:58:20 +00:00
### [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.
2016-06-09 07:26:17 +00:00
### Antigen
2016-05-22 07:07:34 +00:00
2016-05-23 15:58:20 +00:00
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`.
2016-06-09 07:26:17 +00:00
### Oh-My-Zsh
1. `cd ~/.oh-my-zsh/custom/plugins`
2. `git clone git@github.com:psprint/history-search-multi-word.git`
2016-09-13 16:00:18 +00:00
3. Add `history-search-multi-word` to your plugin list
2016-06-09 07:26:17 +00:00
### Zgen
2016-09-13 16:00:18 +00:00
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.
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 ":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)
2016-05-22 07:07:34 +00:00
```
2016-10-25 18:16:44 +00:00
## 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
2016-10-12 14:24:55 +00:00
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)
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-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)