Skip to content
Myr

[shell] Enable sorting by default in CTRL-R

Before adoption: this commit came in with the history the project adopted, so no landing records it.

CTRL-R binding used to start with --no-sort to list the matched commands in chronological order. However, it has been a constant source of confusion. Let's enable it by default from now on. The sorted result shouldn't be too confusing as we use --tiebreak=index.

authored by Junegunn Choi · committed by Junegunn Choi · parent cb9238d · Browse files · 5 files+6 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+6 added−5 removed

  • tests:+1 added−0 removed
  • other:+5 added−5 removed

5 files+6 added−5 removed

modified:shell/key-bindings.bash+1 added-1 removed
modified:shell/key-bindings.fish+1 added-1 removed
43 unmodified lines
4445 function fzf-history-widget -d "Show command history"46 set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40%47 begin48 set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT $FZF_DEFAULT_OPTS +s --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m"48 set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT $FZF_DEFAULT_OPTS --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m"49 history | eval (__fzfcmd) -q '(commandline)' | read -l result50 and commandline -- $result51 end52 commandline -f repaint
35 unmodified lines
modified:shell/key-bindings.zsh+1 added-1 removed
61 unmodified lines
62 emulate -L zsh63 setopt pipefail 2> /dev/null64 local selected num65 selected=( $(fc -l 1 |66 FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS +s --tac -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(q)LBUFFER} +m" $(__fzfcmd)) )66 FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS --tac -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS --query=${(q)LBUFFER} +m" $(__fzfcmd)) )67 local ret=$?68 if [ -n "$selected" ]; then69 num=$selected[1]70 if [ -n "$num" ]; then
11 unmodified lines
modified:test/test_go.rb+1 added
1406 unmodified lines
1407 tmux.prepare1408 tmux.send_keys 'C-r'1409 tmux.until { |lines| lines.item_count > 0 }1410 end1411 tmux.send_keys 'C-r'1412 tmux.send_keys '3d'1413 tmux.until { |lines| lines[-3].end_with? 'echo 3rd' }1414 tmux.send_keys :Enter1415 tmux.until { |lines| lines[-1] == 'echo 3rd' }
235 unmodified lines
modified:README.md+2 added-2 removed
228 unmodified lines
229- `CTRL-T` - Paste the selected files and directories onto the command line230 - Set `FZF_CTRL_T_COMMAND` to override the default command231 - Set `FZF_CTRL_T_OPTS` to pass additional options232- `CTRL-R` - Paste the selected command from history onto the command line233 - Sort is disabled by default to respect chronological ordering234 - Press `CTRL-R` again to toggle sort233 - If you want to see the commands in chronological order, press `CTRL-R`234 again which toggles sorting by relevance235 - Set `FZF_CTRL_R_OPTS` to pass additional options236- `ALT-C` - cd into the selected directory237 - Set `FZF_ALT_C_COMMAND` to override the default command238 - Set `FZF_ALT_C_OPTS` to pass additional options
253 unmodified lines