summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2017-03-03 12:20:01 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2017-03-03 12:20:01 +0900
commitc387689d1cd45f0d8eb122fe95ee72ccc61d3bff (patch)
treef5b8064272d8f91bb0c498c0ae4be854440a8b6b
parentcb9238dc4ee6ee8c9d25fa0c1f6d731b379de9b1 (diff)
[shell] Enable sorting by default in CTRL-R
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.
-rw-r--r--README.md4
-rw-r--r--shell/key-bindings.bash2
-rw-r--r--shell/key-bindings.fish2
-rw-r--r--shell/key-bindings.zsh2
-rw-r--r--test/test_go.rb1
5 files changed, 6 insertions, 5 deletions
diff --git a/README.md b/README.md
index c016de49..b9f9ce38 100644
--- a/README.md
+++ b/README.md
@@ -230,8 +230,8 @@ fish.
- Set `FZF_CTRL_T_COMMAND` to override the default command
- Set `FZF_CTRL_T_OPTS` to pass additional options
- `CTRL-R` - Paste the selected command from history onto the command line
- - Sort is disabled by default to respect chronological ordering
- - Press `CTRL-R` again to toggle sort
+ - If you want to see the commands in chronological order, press `CTRL-R`
+ again which toggles sorting by relevance
- Set `FZF_CTRL_R_OPTS` to pass additional options
- `ALT-C` - cd into the selected directory
- Set `FZF_ALT_C_COMMAND` to override the default command
diff --git a/shell/key-bindings.bash b/shell/key-bindings.bash
index 5a68bc15..4266a407 100644
--- a/shell/key-bindings.bash
+++ b/shell/key-bindings.bash
@@ -56,7 +56,7 @@ __fzf_history__() (
shopt -u nocaseglob nocasematch
line=$(
HISTTIMEFORMAT= history |
- 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 +m" $(__fzfcmd) |
+ FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} $FZF_DEFAULT_OPTS --tac -n2..,.. --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m" $(__fzfcmd) |
command grep '^ *[0-9]') &&
if [[ $- =~ H ]]; then
sed 's/^ *\([0-9]*\)\** .*/!\1/' <<< "$line"
diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish
index c35dac7e..e424f1a1 100644
--- a/shell/key-bindings.fish
+++ b/shell/key-bindings.fish
@@ -45,7 +45,7 @@ function fzf_key_bindings
function fzf-history-widget -d "Show command history"
set -q FZF_TMUX_HEIGHT; or set FZF_TMUX_HEIGHT 40%
begin
- 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"
+ set -lx FZF_DEFAULT_OPTS "--height $FZF_TMUX_HEIGHT $FZF_DEFAULT_OPTS --tiebreak=index --bind=ctrl-r:toggle-sort $FZF_CTRL_R_OPTS +m"
history | eval (__fzfcmd) -q '(commandline)' | read -l result
and commandline -- $result
end
diff --git a/shell/key-bindings.zsh b/shell/key-bindings.zsh
index dbafafb2..e67e3a78 100644
--- a/shell/key-bindings.zsh
+++ b/shell/key-bindings.zsh
@@ -63,7 +63,7 @@ fzf-history-widget() {
setopt pipefail 2> /dev/null
local selected num
selected=( $(fc -l 1 |
- 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)) )
+ 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)) )
local ret=$?
if [ -n "$selected" ]; then
num=$selected[1]
diff --git a/test/test_go.rb b/test/test_go.rb
index 04703757..fef328bb 100644
--- a/test/test_go.rb
+++ b/test/test_go.rb
@@ -1408,6 +1408,7 @@ module TestShell
tmux.send_keys 'C-r'
tmux.until { |lines| lines.item_count > 0 }
end
+ tmux.send_keys 'C-r'
tmux.send_keys '3d'
tmux.until { |lines| lines[-3].end_with? 'echo 3rd' }
tmux.send_keys :Enter