Added options
This commit is contained in:
@@ -34,6 +34,15 @@ Enable it in your `.zshrc` by adding it to your plugin list:
|
||||
plugins=(… zsh-fzf-history-search)
|
||||
```
|
||||
|
||||
## Configuration Variables
|
||||
|
||||
| Variable | Description |
|
||||
| ----------------------------------------- | ------------------------------------------------------------------------------------------------- |
|
||||
| `ZSH_FZF_HISTORY_SEARCH_BIND` | Keybind to trigger fzf reverse search (default: `'^r'`) |
|
||||
| `ZSH_FZF_HISTORY_SEARCH_FZF_ARGS` | Arguments for `fzf` (might be updated, not recommended to override) (default: `'+s +m -x -e'`) |
|
||||
| `ZSH_FZF_HISTORY_SEARCH_FZF_EXTRA_ARGS` | Extra arguments for `fzf` (default: `''`) |
|
||||
|
||||
|
||||
## TODO
|
||||
* use fzf's keybindings for additional functionality (remove specific history item, clear history, etc) while keeping plugin's simplicity in mind ([issue](https://github.com/joshskidmore/zsh-fzf-history-search/issues/10))
|
||||
* better documentation ([issue](https://github.com/joshskidmore/zsh-fzf-history-search/issues/11))
|
||||
|
||||
@@ -1,9 +1,21 @@
|
||||
# do nothing if fzf is not installed
|
||||
(( ! $+commands[fzf] )) && return
|
||||
|
||||
# Bind for fzf history search
|
||||
(( ! ${+ZSH_FZF_HISTORY_SEARCH_BIND} )) &&
|
||||
typeset -g ZSH_FZF_HISTORY_SEARCH_BIND='^r'
|
||||
|
||||
# Args for fzf
|
||||
(( ! ${+ZSH_FZF_HISTORY_SEARCH_FZF_ARGS} )) &&
|
||||
typeset -g ZSH_FZF_HISTORY_SEARCH_FZF_ARGS='+s +m -x -e'
|
||||
|
||||
# Extra args for fzf
|
||||
(( ! ${+ZSH_FZF_HISTORY_SEARCH_FZF_EXTRA_ARGS} )) &&
|
||||
typeset -g ZSH_FZF_HISTORY_SEARCH_FZF_EXTRA_ARGS=''
|
||||
|
||||
fzf_history_search() {
|
||||
setopt extendedglob
|
||||
candidates=(${(f)"$(fc -li -1 0 | fzf +s +m -x -e -q "$BUFFER")"})
|
||||
candidates=(${(f)"$(fc -li -1 0 | fzf $(echo $ZSH_FZF_HISTORY_SEARCH_FZF_ARGS) $(echo $ZSH_FZF_HISTORY_SEARCH_FZF_EXTRA_ARGS) -q "$BUFFER")"})
|
||||
local ret=$?
|
||||
if [ -n "$candidates" ]; then
|
||||
BUFFER="${candidates[@]/(#m)*/${${(As: :)MATCH}[4,-1]}}"
|
||||
@@ -18,4 +30,4 @@ fzf_history_search() {
|
||||
autoload fzf_history_search
|
||||
zle -N fzf_history_search
|
||||
|
||||
bindkey '^r' fzf_history_search
|
||||
bindkey $ZSH_FZF_HISTORY_SEARCH_BIND fzf_history_search
|
||||
|
||||
Reference in New Issue
Block a user