Skip to content
Myr

[fish] History: Operate only on line at cursor

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

This allows inserting history entries when constructing multiline commands.

authored by bitraid · committed by Junegunn Choi · parent 2055db6 · Browse files · 1 file+11 added−4 removed
This commit

State

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

Diff stats

1 file+11 added−4 removed

  • other:+11 added−4 removed

1 file+11 added−4 removed

modified:shell/key-bindings.fish+11 added-4 removed
145 unmodified lines
146 commandline -f repaint147 end148149 function fzf-history-widget -d "Show command history"150 set -l fzf_query (commandline | string escape)150 set -l -- command_line (commandline)151 set -l -- current_line (commandline -L)152 set -l -- total_lines (count $command_line)153 set -l -- fzf_query (string escape -- $command_line[$current_line])154155 set -lx FZF_DEFAULT_OPTS (__fzf_defaults '' \156 '--nth=2..,.. --scheme=history --multi --wrap-sign="\t↳ "' \157 "--bind=ctrl-r:toggle-sort --highlight-line $FZF_CTRL_R_OPTS" \
16 unmodified lines
174 # Merge history from other sessions before searching175 test -z "$fish_private_mode"; and builtin history merge176177 if set -l result (eval $FZF_DEFAULT_COMMAND \| (__fzfcmd) --query=$fzf_query | string split0)175 commandline -- (string replace -a -- \n\t \n $result[1])176 test (count $result) -gt 1; and for i in $result[2..-1]177 commandline -i -- (string replace -a -- \n\t \n \n$i)178 if test "$total_lines" -eq 1179 commandline -- (string replace -a -- \n\t \n $result)180 else181 set -l a (math $current_line - 1)182 set -l b (math $current_line + 1)183 commandline -- $command_line[1..$a] (string replace -a -- \n\t \n $result)184 commandline -a -- '' $command_line[$b..-1]185 end186 end187188 commandline -f repaint
37 unmodified lines