summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-05-29 20:14:56 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-05-29 20:16:49 +0900
commitb4f2cde5ac6e9d625dc6c5ab4c2dcf291e18f3b3 (patch)
tree80e48d8ef5033d85c987753c71c64d38a7ed3e8d /shell
parented53ef7cee216725581a8f0da0422f97cfda02f7 (diff)
downloadfzf-b4f2cde5ac6e9d625dc6c5ab4c2dcf291e18f3b3.tar.gz
[fish] Better multi-line support for CTRL-R
Prepend each entry with an index number so that multi-line entries can be clearly distinguished.
Diffstat (limited to 'shell')
-rw-r--r--shell/key-bindings.fish9
1 files changed, 7 insertions, 2 deletions
diff --git a/shell/key-bindings.fish b/shell/key-bindings.fish
index 150de0fa..b39424c2 100644
--- a/shell/key-bindings.fish
+++ b/shell/key-bindings.fish
@@ -69,8 +69,13 @@ function fzf_key_bindings
# history's -z flag was added in fish 2.4.0, so don't use it for versions
# before 2.4.0.
if [ "$FISH_MAJOR" -gt 2 -o \( "$FISH_MAJOR" -eq 2 -a "$FISH_MINOR" -ge 4 \) ];
- history -z | eval (__fzfcmd) --read0 --print0 -q '(commandline)' | read -lz result
- and commandline -- $result
+ if type -q perl
+ history -z --reverse | perl -0 -pe 's/^/$.\t/g; s/\n/\n\t/gm' | eval (__fzfcmd) --tac --read0 --print0 -q '(commandline)' | sed 's/^[0-9]*\t//' | read -lz result
+ and commandline -- $result
+ else
+ history -z | eval (__fzfcmd) --read0 --print0 -q '(commandline)' | read -lz result
+ and commandline -- $result
+ end
else
history | eval (__fzfcmd) -q '(commandline)' | read -l result
and commandline -- $result