Skip to content
Myr

[fish] Format history using builtins if perl is missing

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

authored by bitraid · committed by Junegunn Choi · parent ed76f07 · Browse files · 1 file+8 added−6 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+8 added−6 removed

  • other:+8 added−6 removed

1 file+8 added−6 removed

modified:shell/key-bindings.fish+8 added-6 removed
69 unmodified lines
70 # history's -z flag is needed for multi-line support.71 # history's -z flag was added in fish 2.4.0, so don't use it for versions72 # before 2.4.0.73 if [ "$FISH_MAJOR" -gt 2 -o \( "$FISH_MAJOR" -eq 2 -a "$FISH_MINOR" -ge 4 \) ];74 if type -P perl > /dev/null 2>&175 set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"\t"↳ ' --highlight-line $FZF_CTRL_R_OPTS +m")76 set -lx FZF_DEFAULT_OPTS_FILE ''74 set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"\t"↳ ' --highlight-line $FZF_CTRL_R_OPTS +m")75 set -lx FZF_DEFAULT_OPTS_FILE ''76 if type -q perl77 builtin history -z --reverse | command perl -0 -pe 's/^/$.\t/g; s/\n/\n\t/gm' | eval (__fzfcmd) --tac --read0 --print0 -q '(commandline)' | string replace -r '^\d*\t' '' | read -lz result78 and commandline -- $result79 else80 set -lx FZF_DEFAULT_OPTS (__fzf_defaults "" "--scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"\t"↳ ' --highlight-line $FZF_CTRL_R_OPTS +m")81 set -lx FZF_DEFAULT_OPTS_FILE ''82 builtin history -z | eval (__fzfcmd) --read0 --print0 -q '(commandline)' | read -lz result80 set -l line 081 for i in (builtin history -z --reverse | string split0)82 set line (math $line + 1)83 string escape -n -- $line\t$i84 end | string join0 | string replace -a '\n' '\n\t' | string unescape -n | eval (__fzfcmd) --tac --read0 --print0 -q '(commandline)' | string replace -r '^\d*\t' '' | read -lz result85 and commandline -- $result86 end87 else88 builtin history | eval (__fzfcmd) -q '(commandline)' | read -l result
121 unmodified lines