Created
February 15, 2020 21:44
-
-
Save AHPanna/2a67e9b975016f94190e9374eb4a5788 to your computer and use it in GitHub Desktop.
fzf binding .bashrc and fish functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install fzf : | |
bash in the bachrc : | |
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 | |
} | |
and on fish : | |
wget or curl this file : to path : $HOME/.config/fish/functions/ | |
https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.fish | |
and then add the bind key to fish_prompt.fish | |
after function : | |
bind \cr 'fzf_key_bindings' | |
just do a ctrl+r to launch the fzf interactive. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment