From ba8efffd070b612ca6e4197f259d8a20728d9753 Mon Sep 17 00:00:00 2001 From: Martin Dvorak Date: Sat, 7 Dec 2019 22:44:28 +0100 Subject: [PATCH] Improving zsh related documentation + fixing zsh bindkey as suggested by @hoto in #248 --- CONFIGURATION.md | 12 +++++++++--- README.md | 6 +++++- man/hstr.1 | 6 +++--- src/hstr.c | 6 +++--- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 2b22ddd..35dff1b 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -2,10 +2,16 @@ Get most of HSTR by configuring it with: ```bash +# bash hstr --show-configuration >> ~/.bashrc + +# zsh +hstr --show-configuration >> ~/.zshrc ``` -Run `hstr --show-configuration` to determine what will be appended to your Bash profile. Don't forget to `source ~/.bashrc` to apply changes. +Run `hstr --show-configuration` to determine what will be appended to your +bash / zsh profile. Don't forget to `source ~/.bashrc` / `source ~/.zshrc` +to apply changes. --- @@ -28,7 +34,7 @@ For more configuration options details please refer to: Check also configuration [examples](#examples). -## Binding HSTR to Keyboard Shortcut +## Bash Binding HSTR to Keyboard Shortcut Bash uses *Emacs* style keyboard shortcuts by default. There is also *Vi* mode. Find out how to bind HSTR to a keyboard shortcut based on the style you prefer below. @@ -91,7 +97,7 @@ bind '"\C-r": "\e0ihstr -- \C-j"' Bind HSTR to a `zsh` key e.g. to Ctrlr: ```bash -bindkey -s "\C-r" "\eqhstr --\n" +bindkey -s "\C-r" "\C-ahstr -- \C-j" ``` diff --git a/README.md b/README.md index ac08c18..890684c 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Current release](https://img.shields.io/github/release/dvorka/hstr.svg)](https://github.com/dvorka/hstr/releases) [![GitHub issues](https://img.shields.io/github/issues/dvorka/hstr.svg?maxAge=360)](https://github.com/dvorka/hstr/issues) [![All releases downloads](https://img.shields.io/github/downloads/dvorka/hstr/total.svg)](https://github.com/dvorka/hstr/releases) -[![AUR](https://img.shields.io/aur/license/yaourt.svg)](https://github.com/dvorka/hstr/blob/master/LICENSE) +[![License](https://img.shields.io/github/license/dvorka/hstr?color=%23fe0000)](https://github.com/dvorka/hstr/blob/master/LICENSE) Easily view, navigate and search your **command history** with shell history suggest box for Bash and [zsh](CONFIGURATION.md#zsh-history-settings). @@ -66,7 +66,11 @@ Tarball: Configure HSTR just by running: ```bash +# bash hstr --show-configuration >> ~/.bashrc + +# zsh +hstr --show-configuration >> ~/.zshrc ``` For detailed HSTR configuration documentation please refer to [Configuration](CONFIGURATION.md). diff --git a/man/hstr.1 b/man/hstr.1 index 8eca5b7..05f72b0 100644 --- a/man/hstr.1 +++ b/man/hstr.1 @@ -188,9 +188,9 @@ if [[ $\- =~ .*i.* ]]; then bind '"\eC\-r": "\eC\-a hstr -- \eC-j"'; fi Optionally add the following lines to ~/.zshrc: .nf .sp -export HISTFILE=~/.zsh_history # ensure history file visibility -export HSTR_CONFIG=hicolor # get more colors -bindkey -s "\eC\-r" "\eeqhstr\en" # bind hstr to Ctrl-r (for Vi mode check doc, experiment with --) +export HISTFILE=~/.zsh_history # ensure history file visibility +export HSTR_CONFIG=hicolor # get more colors +bindkey -s "\eC\-r" "\eC\-ahstr \-\- \eC\-j" # bind hstr to Ctrl-r (for Vi mode check doc) .sp .fi .SH EXAMPLES diff --git a/src/hstr.c b/src/hstr.c index 90b6971..f33b9e2 100644 --- a/src/hstr.c +++ b/src/hstr.c @@ -205,7 +205,7 @@ static const char* INSTALL_BASH_STRING= static const char* INSTALL_ZSH_STRING= "\n# HSTR configuration - add this to ~/.bashrc" "\nalias hh=hstr # hh to be alias for hstr" - "\nexport HISTFILE=~/.zsh_history # ensure history file visibility" + "\nexport HISTFILE=~/.zsh_history # ensure history file visibility" "\nexport HSTR_CONFIG=hicolor # get more colors" #if defined(__MS_WSL__) // TODO binding to be rewritten for zsh@WSL as it's done for Bash - hstr_winwsl() like function to be implemented to make it work on WSL @@ -238,13 +238,13 @@ static const char* INSTALL_ZSH_STRING= "\n" "\nbindkey -s \"\\C-r\" \"\\eqhstr\\n\" # bind hstr to Ctrl-r (for Vi mode check doc)" #else - "\nbindkey -s \"\\C-r\" \"\\eqhstr\\n\" # bind hstr to Ctrl-r (for Vi mode check doc)" + "\nbindkey -s \"\\C-r\" \"\\C-ahstr -- \\C-j\" # bind hstr to Ctrl-r (for Vi mode check doc)" #endif // TODO try variant with args/pars separation //"\nbindkey -s \"\\C-r\" \"\\eqhstr --\\n\" # bind hstr to Ctrl-r (for Vi mode check doc)" // alternate binding options in zsh: // bindkey -s '^R' '^Ahstr ^M' - // bindkey -s "\C-r" "\C-ahstr \C-j" + // bindkey -s "\C-r" "\C-ahstr -- \C-j" "\n\n"; static const char* HELP_STRING=