mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[zsh] add history search with fzf
This commit is contained in:
parent
3c8dd0f9f2
commit
d184233b67
3 changed files with 24 additions and 2 deletions
|
@ -43,7 +43,7 @@ _palette_widget() {
|
|||
# try to fill in a placeholder if there're any, otherwise pick a snippet
|
||||
if ! _palette_fill_in_placeholder; then
|
||||
local selected
|
||||
if selected="$(_palette_parse_tldr_pages | fzf --ansi --cycle --height 50% --reverse)"
|
||||
if selected="$(_palette_parse_tldr_pages | fzf --height 40% --reverse --ansi)"
|
||||
then
|
||||
# paste selected snippet without its description
|
||||
zle -U "${selected%%$PALETTE_SNIPPET_COMMENT*}"
|
||||
|
|
22
zsh/zle.zsh
Normal file
22
zsh/zle.zsh
Normal file
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
if command_exists fzf; then
|
||||
# taken from https://github.com/junegunn/fzf/blob/master/shell/key-bindings.zsh
|
||||
fzf-history-widget() {
|
||||
setopt localoptions pipefail
|
||||
local selected
|
||||
selected=(
|
||||
$(fc -rl 1 |
|
||||
fzf --height=40% --reverse --nth=2.. --tiebreak=index --query="$LBUFFER")
|
||||
)
|
||||
local fzf_ret="$?"
|
||||
if (( ${#selected} )); then
|
||||
zle vi-fetch-history -n "${selected[1]}"
|
||||
fi
|
||||
zle reset-prompt
|
||||
return "$fzf_ret"
|
||||
}
|
||||
|
||||
zle -N fzf-history-widget
|
||||
bindkey '^[r' fzf-history-widget
|
||||
fi
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
ZSH_DOTFILES="${0:h}"
|
||||
|
||||
for script in functions path env plugins aliases palette prompt; do
|
||||
for script in functions path env plugins aliases zle palette prompt; do
|
||||
source "$ZSH_DOTFILES/$script.zsh"
|
||||
source_if_exists "$ZSH_DOTFILES/custom/$script.zsh"
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue