keyboard-shortcutszshfzf

Bind "up arrow" key to fzf command


I want to use the fzf fuzzyfinder command history instead of the typical command history when I press the up arrow.

In my fzf shell keybindings file I'm able to edit which key brings up the fuzzy finder by editing the following snippet:

bindkey '{command such as ^R}' fzf-history-widget

How can I represent the up arrow key so that it calls this function when pressed? Do I have to disable other functionality somewhere else as well?


Solution

  • Binding <Up> key in zsh

    Use

    bindkey "${key[Up]}" fzf-history-widget
    

    or

    bindkey '^[[A' fzf-history-widget
    

    or

    bindkey "${terminfo[kcuu1]}" up-line-or-history
    

    to bind <Up> key in zsh to fzf-history-widget function.

    Binding <Up> key in bash

    You can set the <Up> arrow key to show the commands from history beginning with the characters before the cursor on the command line

    bind '"\e[A": history-search-backward'
    

    fzf bindings for bash

    There is an issue #1492: [bash] Fire command directly with CTRL-X in CTRL-R

    Accordingly, history-exec.bash plugin created for the purpose of history expansion using fzf

    macOS Specific Binding

    bindkey "${terminfo[kcuu1]}" fzf-history-widget