Skip to content
Myr

key-bindings.bash

This file

Path

shell/key-bindings.bash

125 lines · 4.4 KiB · Shell

Last changed by

[bash] Fall back to send-keys if named paste buffer is not supportedJunegunn Choibefore adoption3a4e053

History of this file

Take it

The walk stopped after 200 commits: lines older than 1c20255 point at it.

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 1–7why, one step back
1# Key bindings
2# ------------3__fzf_select__() {4 local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \5 -o -type f -print \6 -o -type d -print \7 -o -type l -print 2> /dev/null | sed 1d | cut -b3-"}"

[shell] Add $FZF_CTRL_T_OPTS and $FZF_ALT_C_OPTSJunegunn Choibefore adoptionc39c039

line 8why, one step back
8 eval "$cmd | fzf -m $FZF_CTRL_T_OPTS" | while read -r item; do

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 9–16why, one step back
9 printf '%q ' "$item"
10 done11 echo12}1314if [[ $- =~ i ]]; then1516__fzfcmd() {

[bash] Fix shellcheck warningsJunegunn Choibefore adoption09a2ab3

line 17why, one step back
17 [ "${FZF_TMUX:-1}" != 0 ] && echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 18–27why, one step back
18}
1920__fzf_select_tmux__() {21 local height22 height=${FZF_TMUX_HEIGHT:-40%}23 if [[ $height =~ %$ ]]; then24 height="-p ${height%\%}"25 else26 height="-l $height"27 fi

Merge pull request #455 from frizinak/masterJunegunn Choibefore adoptionc8a3f6f

line 28why, one step back
28

[bash] Fall back to send-keys if named paste buffer is not supportedJunegunn Choibefore adoption3a4e053

line 29why, one step back
29 tmux split-window $height "cd $(printf %q "$PWD"); FZF_DEFAULT_OPTS=$(printf %q "$FZF_DEFAULT_OPTS") PATH=$(printf %q "$PATH") FZF_CTRL_T_COMMAND=$(printf %q "$FZF_CTRL_T_COMMAND") FZF_CTRL_T_OPTS=$(printf %q "$FZF_CTRL_T_OPTS") bash -c 'source \"${BASH_SOURCE[0]}\"; RESULT=\"\$(__fzf_select__)\"; tmux setb -b fzf \"\$RESULT\" \\; pasteb -b fzf -t $TMUX_PANE \\; deleteb -b fzf || tmux send-keys -t $TMUX_PANE \"\$RESULT\"'"

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 30–31why, one step back
30}
31

[bash] Export fzf-file-widget function for bash 4+ (#546)Junegunn Choibefore adoptiond86cee2

lines 32–33why, one step back
32fzf-file-widget() {
33 if __fzf_use_tmux__; then

Merge pull request #446 from chaoren/masterJunegunn Choibefore adoptionac0a62e

lines 34–35why, one step back
34 __fzf_select_tmux__
35 else

[bash] Export fzf-file-widget function for bash 4+ (#546)Junegunn Choibefore adoptiond86cee2

lines 36–38why, one step back
36 local selected="$(__fzf_select__)"
37 READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$selected${READLINE_LINE:$READLINE_POINT}"38 READLINE_POINT=$(( READLINE_POINT + ${#selected} ))

Merge pull request #446 from chaoren/masterJunegunn Choibefore adoptionac0a62e

lines 39–41why, one step back
39 fi
40}41

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 42–45why, one step back
42__fzf_cd__() {
43 local cmd dir44 cmd="${FZF_ALT_C_COMMAND:-"command find -L . \\( -path '*/\\.*' -o -fstype 'dev' -o -fstype 'proc' \\) -prune \45 -o -type d -print 2> /dev/null | sed 1d | cut -b3-"}"

[shell] Add $FZF_CTRL_T_OPTS and $FZF_ALT_C_OPTSJunegunn Choibefore adoptionc39c039

line 46why, one step back
46 dir=$(eval "$cmd | $(__fzfcmd) +m $FZF_ALT_C_OPTS") && printf 'cd %q' "$dir"

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 47–53why, one step back
47}
4849__fzf_history__() (50 local line51 shopt -u nocaseglob nocasematch52 line=$(53 HISTTIMEFORMAT= history |

[bash/zsh] Fix $FZF_CTRL_R_OPTS with option values with spacesJunegunn Choibefore adoption95b34de

line 54why, one step back
54 eval "$(__fzfcmd) +s --tac +m -n2..,.. --tiebreak=index --toggle-sort=ctrl-r $FZF_CTRL_R_OPTS" |

[shell] Suppress alias/function expansionJunegunn Choibefore adoption6081eac

line 55why, one step back
55 command grep '^ *[0-9]') &&

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 56–62why, one step back
56 if [[ $- =~ H ]]; then
57 sed 's/^ *\([0-9]*\)\** .*/!\1/' <<< "$line"58 else59 sed 's/^ *\([0-9]*\)\** *//' <<< "$line"60 fi61)62

[bash] Export fzf-file-widget function for bash 4+ (#546)Junegunn Choibefore adoptiond86cee2

lines 63–65why, one step back
63__fzf_use_tmux__() {
64 [ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-1}" != 0 ] && [ ${LINES:-40} -gt 15 ]65}

Fix typos in help messageJunegunn Choibefore adoption1c20255

line 66why, one step back
66

[bash] Export fzf-file-widget function for bash 4+ (#546)Junegunn Choibefore adoptiond86cee2

lines 67–69why, one step back
67[ $BASH_VERSINFO -gt 3 ] && __use_bind_x=1 || __use_bind_x=0
68__fzf_use_tmux__ && __use_tmux=1 || __use_tmux=069

[bash] Use backticks to avoid delay with blink-matching-parenJunegunn Choibefore adoptione0b29e4

line 70why, one step back
70if [[ ! -o vi ]]; then

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 71–75why, one step back
71 # Required to refresh the prompt after fzf
72 bind '"\er": redraw-current-line'73 bind '"\e^": history-expand-line'7475 # CTRL-T - Paste the selected file path into the command line

[bash] Export fzf-file-widget function for bash 4+ (#546)Junegunn Choibefore adoptiond86cee2

lines 76–77why, one step back
76 if [ $__use_bind_x -eq 1 ]; then
77 bind -x '"\C-t": "fzf-file-widget"'

Merge pull request #446 from chaoren/masterJunegunn Choibefore adoptionac0a62e

line 78why, one step back
78 elif [ $__use_tmux -eq 1 ]; then

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 79–84why, one step back
79 bind '"\C-t": " \C-u \C-a\C-k$(__fzf_select_tmux__)\e\C-e\C-y\C-a\C-d\C-y\ey\C-h"'
80 else81 bind '"\C-t": " \C-u \C-a\C-k$(__fzf_select__)\e\C-e\C-y\C-a\C-y\ey\C-h\C-e\er \C-h"'82 fi8384 # CTRL-R - Paste the selected command from history into the command line

[bash] Use backticks to avoid delay with blink-matching-parenJunegunn Choibefore adoptione0b29e4

line 85why, one step back
85 bind '"\C-r": " \C-e\C-u`__fzf_history__`\e\C-e\e^\er"'

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 86–87why, one step back
86
87 # ALT-C - cd into the selected directory

[bash] Use backticks to avoid delay with blink-matching-parenJunegunn Choibefore adoptione0b29e4

line 88why, one step back
88 bind '"\ec": " \C-e\C-u`__fzf_cd__`\e\C-e\er\C-m"'

Fix typos in help messageJunegunn Choibefore adoption1c20255

line 89why, one step back
89else

Merge pull request #540 from WChargin/bash-vimode-delay-fixJunegunn Choibefore adoptiond9ce797

lines 90–98why, one step back
90 # We'd usually use "\e" to enter vi-movement-mode so we can do our magic,
91 # but this incurs a very noticeable delay of a half second or so,92 # because many other commands start with "\e".93 # Instead, we bind an unused key, "\C-x\C-a",94 # to also enter vi-movement-mode,95 # and then use that thereafter.96 # (We imagine that "\C-x\C-a" is relatively unlikely to be in use.)97 bind '"\C-x\C-a": vi-movement-mode'98

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 99–104why, one step back
99 bind '"\C-x\C-e": shell-expand-line'
100 bind '"\C-x\C-r": redraw-current-line'101 bind '"\C-x^": history-expand-line'102103 # CTRL-T - Paste the selected file path into the command line104 # - FIXME: Selected items are attached to the end regardless of cursor position

[bash] Export fzf-file-widget function for bash 4+ (#546)Junegunn Choibefore adoptiond86cee2

lines 105–106why, one step back
105 if [ $__use_bind_x -eq 1 ]; then
106 bind -x '"\C-t": "fzf-file-widget"'

Merge pull request #446 from chaoren/masterJunegunn Choibefore adoptionac0a62e

line 107why, one step back
107 elif [ $__use_tmux -eq 1 ]; then

Merge pull request #540 from WChargin/bash-vimode-delay-fixJunegunn Choibefore adoptiond9ce797

line 108why, one step back
108 bind '"\C-t": "\C-x\C-a$a \C-x\C-addi$(__fzf_select_tmux__)\C-x\C-e\C-x\C-a0P$xa"'

Fix typos in help messageJunegunn Choibefore adoption1c20255

line 109why, one step back
109 else

Merge pull request #540 from WChargin/bash-vimode-delay-fixJunegunn Choibefore adoptiond9ce797

line 110why, one step back
110 bind '"\C-t": "\C-x\C-a$a \C-x\C-addi$(__fzf_select__)\C-x\C-e\C-x\C-a0Px$a \C-x\C-r\C-x\C-axa "'

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 111–114why, one step back
111 fi
112 bind -m vi-command '"\C-t": "i\C-t"'113114 # CTRL-R - Paste the selected command from history into the command line

Merge pull request #540 from WChargin/bash-vimode-delay-fixJunegunn Choibefore adoptiond9ce797

line 115why, one step back
115 bind '"\C-r": "\C-x\C-addi$(__fzf_history__)\C-x\C-e\C-x^\C-x\C-a$a\C-x\C-r"'

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 116–118why, one step back
116 bind -m vi-command '"\C-r": "i\C-r"'
117118 # ALT-C - cd into the selected directory

Merge pull request #540 from WChargin/bash-vimode-delay-fixJunegunn Choibefore adoptiond9ce797

lines 119–120why, one step back
119 bind '"\ec": "\C-x\C-addi$(__fzf_cd__)\C-x\C-e\C-x\C-r\C-m"'
120 bind -m vi-command '"\ec": "ddi$(__fzf_cd__)\C-x\C-e\C-x\C-r\C-m"'

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 121–122why, one step back
121fi
122

[bash] Export fzf-file-widget function for bash 4+ (#546)Junegunn Choibefore adoptiond86cee2

line 123why, one step back
123unset -v __use_tmux __use_bind_x

Fix typos in help messageJunegunn Choibefore adoption1c20255

lines 124–125why, one step back
124
125fi