history-search-multi-word/README.md

195 lines
8 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)
2018-08-04 14:27:50 +00:00
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=H4GZAACT2MQ3W)
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
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
* 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`).
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-06-09 07:26:17 +00:00
### Oh-My-Zsh
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-06-09 07:26:17 +00:00
### Zgen
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-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)
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
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
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-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)