No description
Find a file
Sebastian Gniazdowski 60710d31b5 *highlighting: Optimization – remove *add-highlight function
parse.zsh -o, before changes:

Running time: 0.9516510000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350         945,28     2,70  100,00%    632,08     1,81   66,87%  -hsmw-highlight-process
 2) 3150          62,92     0,02    6,66%     62,92     0,02    6,66%  -hsmw-add-highlight
 3)  950          80,01     0,08    8,46%     58,97     0,06    6,24%  -hsmw-highlight-check-path
 4)  300          58,21     0,19    6,16%     57,09     0,19    6,04%  -hsmw-highlight-string
 5) 1950          43,18     0,02    4,57%     43,18     0,02    4,57%  -hsmw-highlight-expand-path
 6) 1000          36,50     0,04    3,86%     36,50     0,04    3,86%  -hsmw-highlight-main-type
 7) 1000          28,77     0,03    3,04%     28,77     0,03    3,04%  (anon)
 8) 3100          19,17     0,01    2,03%     19,17     0,01    2,03%  -hsmw-highlight-is-redirection

parse.zsh -o, after changes:

Running time: 0.8807530000
num  calls                time                       self            name
-----------------------------------------------------------------------------------
 1)  350         874,42     2,50  100,00%    630,15     1,80   72,06%  -hsmw-highlight-process
 2)  950          78,16     0,08    8,94%     57,66     0,06    6,59%  -hsmw-highlight-check-path
 3)  300          57,42     0,19    6,57%     57,42     0,19    6,57%  -hsmw-highlight-string
 4) 1950          41,83     0,02    4,78%     41,83     0,02    4,78%  -hsmw-highlight-expand-path
 5) 1000          33,57     0,03    3,84%     33,57     0,03    3,84%  -hsmw-highlight-main-type
 6) 1000          28,36     0,03    3,24%     28,36     0,03    3,24%  (anon)
 7) 3100          18,92     0,01    2,16%     18,92     0,01    2,16%  -hsmw-highlight-is-redirection
 8)  200           3,20     0,02    0,37%      3,20     0,02    0,37%  -hsmw-highlight-check-assign

( 1084 - 847 ) / 1084.0 = 0.2186
2016-10-15 14:40:02 +02:00
test parse.zsh: Use zprof 2016-10-15 09:56:08 +02:00
history-search-multi-word hsmw: autoload is-at-least 2016-10-15 09:36:08 +02:00
history-search-multi-word.plugin.zsh Immediate commit after obtaining first working highlighting 2016-10-09 09:24:03 +02:00
hsmw-highlight *highlighting: Optimization – remove *add-highlight function 2016-10-15 14:40:02 +02:00
LICENSE New license 2016-08-31 17:09:24 +02:00
README.md Updated README.md 2016-10-15 08:24:50 +02:00

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. You can resize the video by pressing Ctrl-+ or Cmd-+.

asciicast

News

  • 11-10-2016

    • Syntax highlighting of history  adapted, fine crafted, small part of zsh-syntax-highlighting to color what hsmw shows:

      syntax highlighting

  • 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

  • 25-05-2016

    • Cooperation with zsh-autosuggestions plugin

    • Configuration option to set page size, example use:

      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

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

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

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 of hsmw-highlight file. Example ~/.zshrc addition that sets path key paths that exist will be highlighted with background magenta, foreground white, bold:

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:

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 (SSL) or chat.freenode.net:6667 and join #zplugin.

Following is a quick access via Webchat IRC