key-bindings.bash
This file
Path
shell/key-bindings.bash
96 lines · 3.6 KiB · Shell
Last changed by
[fzf-tmux] Fall back to plain fzf when split failedJunegunn Choibefore adoption540bfd7
History of this fileTake it
The walk stopped after 200 commits: lines older than 8cf45a5 point at it.
[fzf-tmux] Add option to start fzf in tmux popup windowJunegunn Choibefore adoptionbf65e8c
lines 1–13why, one step back1# ____ ____2# / __/___ / __/3# / /_/_ / / /_4# / __/ / /_/ __/5# /_/ /___/_/ key-bindings.bash6#7# - $FZF_TMUX_OPTS8# - $FZF_CTRL_T_COMMAND9# - $FZF_CTRL_T_OPTS10# - $FZF_CTRL_R_OPTS11# - $FZF_ALT_C_COMMAND12# - $FZF_ALT_C_OPTS13[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
lines 14–20why, one step back14# Key bindings15# ------------16__fzf_select__() {17 local cmd="${FZF_CTRL_T_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \18 -o -type f -print \19 -o -type d -print \20 -o -type l -print 2> /dev/null | cut -b3-"}"[fzf-tmux] Add option to start fzf in tmux popup windowJunegunn Choibefore adoptionbf65e8c
line 21why, one step back21 eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS" $(__fzfcmd) -m "$@" | while read -r item; do[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
lines 22–29why, one step back22 printf '%q ' "$item"23 done24 echo25}2627if [[ $- =~ i ]]; then2829__fzfcmd() {[fzf-tmux] Fall back to plain fzf when split failedJunegunn Choibefore adoption540bfd7
line 30why, one step back30 [ -n "$TMUX_PANE" ] && { [ "${FZF_TMUX:-0}" != 0 ] || [ -n "$FZF_TMUX_OPTS" ]; } &&[fzf-tmux] Add option to start fzf in tmux popup windowJunegunn Choibefore adoptionbf65e8c
line 31why, one step back31 echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
lines 32–34why, one step back32}3334fzf-file-widget() {[fzf-tmux] Add option to start fzf in tmux popup windowJunegunn Choibefore adoptionbf65e8c
lines 35–37why, one step back35 local selected="$(__fzf_select__)"36 READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$selected${READLINE_LINE:$READLINE_POINT}"37 READLINE_POINT=$(( READLINE_POINT + ${#selected} ))[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
lines 38–46why, one step back38}3940__fzf_cd__() {41 local cmd dir42 cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \43 -o -type d -print 2> /dev/null | cut -b3-"}"44 dir=$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m) && printf 'cd %q' "$dir"45}46[bash] Start C-r search with current command line (#1886)Jack Batesbefore adoption7c447bb
lines 47–49why, one step back47__fzf_history__() {48 local output49 output=$([bash] Multiline C-r without histexpand (#1837)Jack Batesbefore adoption5cae8ea
line 50why, one step back50 builtin fc -lnr -2147483648 |[shell] Update CTRL-R to remove duplicate commandsJunegunn Choibefore adoption18261fe
line 51why, one step back51 last_hist=$(HISTTIMEFORMAT='' builtin history 1) perl -n -l0 -e 'BEGIN { getc; $/ = "\n\t"; $HISTCMD = $ENV{last_hist} + 1 } s/^[ *]//; print $HISTCMD - $. . "\t$_" if !$seen{$_}++' |[bash] Restore --nth option in CTRL-RJunegunn Choibefore adoption14f9050
line 52why, one step back52 FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m --read0" $(__fzfcmd) --query "$READLINE_LINE"[bash] Start C-r search with current command line (#1886)Jack Batesbefore adoption7c447bb
lines 53–60why, one step back53 ) || return54 READLINE_LINE=${output#*$'\t'}55 if [ -z "$READLINE_POINT" ]; then56 echo "$READLINE_LINE"57 else58 READLINE_POINT=0x7fffffff59 fi60}[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
line 61why, one step back61[bash] Populate emacs and vi keymaps (#1815)Jack Batesbefore adoption82bf8c1
lines 62–63why, one step back62# Required to refresh the prompt after fzf63bind -m emacs-standard '"\er": redraw-current-line'[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
line 64why, one step back64[bash] Put C-t items at point in vi mode (#1876)Jack Batesbefore adoption9c293bb
lines 65–67why, one step back65bind -m vi-command '"\C-z": emacs-editing-mode'66bind -m vi-insert '"\C-z": emacs-editing-mode'67bind -m emacs-standard '"\C-z": vi-editing-mode'[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
line 68why, one step back68[bash] Start C-r search with current command line (#1886)Jack Batesbefore adoption7c447bb
lines 69–70why, one step back69if [ "${BASH_VERSINFO[0]}" -lt 4 ]; then70 # CTRL-T - Paste the selected file path into the command line[fzf-tmux] Add option to start fzf in tmux popup windowJunegunn Choibefore adoptionbf65e8c
line 71why, one step back71 bind -m emacs-standard '"\C-t": " \C-b\C-k \C-u`__fzf_select__`\e\C-e\er\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f"'[bash] Start C-r search with current command line (#1886)Jack Batesbefore adoption7c447bb
lines 72–73why, one step back72 bind -m vi-command '"\C-t": "\C-z\C-t\C-z"'73 bind -m vi-insert '"\C-t": "\C-z\C-t\C-z"'[bash] Populate emacs and vi keymaps (#1815)Jack Batesbefore adoption82bf8c1
line 74why, one step back74[bash] Start C-r search with current command line (#1886)Jack Batesbefore adoption7c447bb
lines 75–83why, one step back75 # CTRL-R - Paste the selected command from history into the command line76 bind -m emacs-standard '"\C-r": "\C-e \C-u\C-y\ey\C-u"$(__fzf_history__)"\e\C-e\er"'77 bind -m vi-command '"\C-r": "\C-z\C-r\C-z"'78 bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"'79else80 # CTRL-T - Paste the selected file path into the command line81 bind -m emacs-standard -x '"\C-t": fzf-file-widget'82 bind -m vi-command -x '"\C-t": fzf-file-widget'83 bind -m vi-insert -x '"\C-t": fzf-file-widget'[bash] Populate emacs and vi keymaps (#1815)Jack Batesbefore adoption82bf8c1
line 84why, one step back84[bash] Start C-r search with current command line (#1886)Jack Batesbefore adoption7c447bb
lines 85–90why, one step back85 # CTRL-R - Paste the selected command from history into the command line86 bind -m emacs-standard -x '"\C-r": __fzf_history__'87 bind -m vi-command -x '"\C-r": __fzf_history__'88 bind -m vi-insert -x '"\C-r": __fzf_history__'89fi90[bash] Populate emacs and vi keymaps (#1815)Jack Batesbefore adoption82bf8c1
line 91why, one step back91# ALT-C - cd into the selected directory[bash] Start C-r search with current command line (#1886)Jack Batesbefore adoption7c447bb
line 92why, one step back92bind -m emacs-standard '"\ec": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d"'[bash] Put C-t items at point in vi mode (#1876)Jack Batesbefore adoption9c293bb
lines 93–94why, one step back93bind -m vi-command '"\ec": "\C-z\ec\C-z"'94bind -m vi-insert '"\ec": "\C-z\ec\C-z"'[shell] Skip loading completion code on non-interactive shellJunegunn Choibefore adoption8cf45a5
lines 95–96why, one step back9596fi