fzf
This commit is contained in:
parent
0b49a29872
commit
3130ff5b87
2 changed files with 33 additions and 1 deletions
23
zsh/funcs/fzf.funcs
Normal file
23
zsh/funcs/fzf.funcs
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# from the fzf examples wiki
|
||||||
|
bind '"\C-r": "\C-x1\e^\er"'
|
||||||
|
bind -x '"\C-x1": __fzf_history';
|
||||||
|
|
||||||
|
__fzf_history ()
|
||||||
|
{
|
||||||
|
__ehc $(history | fzf --tac --tiebreak=index | perl -ne 'm/^\s*([0-9]+)/ and print "!$1"')
|
||||||
|
}
|
||||||
|
|
||||||
|
__ehc()
|
||||||
|
{
|
||||||
|
if
|
||||||
|
[[ -n $1 ]]
|
||||||
|
then
|
||||||
|
bind '"\er": redraw-current-line'
|
||||||
|
bind '"\e^": magic-space'
|
||||||
|
READLINE_LINE=${READLINE_LINE:+${READLINE_LINE:0:READLINE_POINT}}${1}${READLINE_LINE:+${READLINE_LINE:READLINE_POINT}}
|
||||||
|
READLINE_POINT=$(( READLINE_POINT + ${#1} ))
|
||||||
|
else
|
||||||
|
bind '"\er":'
|
||||||
|
bind '"\e^":'
|
||||||
|
fi
|
||||||
|
}
|
11
zsh/zshrc
11
zsh/zshrc
|
@ -43,7 +43,6 @@ source $HOME/.antigen/antigen.zsh
|
||||||
antigen use oh-my-zsh
|
antigen use oh-my-zsh
|
||||||
|
|
||||||
antigen bundle git
|
antigen bundle git
|
||||||
antigen bundle command-not-found
|
|
||||||
antigen bundle vi-mode
|
antigen bundle vi-mode
|
||||||
antigen bundle zsh-users/zsh-syntax-highlighting
|
antigen bundle zsh-users/zsh-syntax-highlighting
|
||||||
antigen bundle zsh-users/zsh-completions
|
antigen bundle zsh-users/zsh-completions
|
||||||
|
@ -155,6 +154,16 @@ else
|
||||||
touch $HOME/.zshsrc
|
touch $HOME/.zshsrc
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
function fzf_hist() {
|
||||||
|
local sed_cmd
|
||||||
|
if [[ $(uname -s) == "Darwin" ]]; then
|
||||||
|
sed_cmd='sed -E'
|
||||||
|
else
|
||||||
|
sed_cmd='sed -r'
|
||||||
|
fi
|
||||||
|
print -z $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | $($sed_cmd 's/ *[0-9]*\*? *//') | ${sed_cmd} 's/\\/\\\\/g')
|
||||||
|
}
|
||||||
|
|
||||||
export PATH="$PATH:$HOME/.anyenv/bin"
|
export PATH="$PATH:$HOME/.anyenv/bin"
|
||||||
eval "$(anyenv init -)"
|
eval "$(anyenv init -)"
|
||||||
export PATH="$(yarn global bin):$PATH"
|
export PATH="$(yarn global bin):$PATH"
|
||||||
|
|
Loading…
Add table
Reference in a new issue