Skip to content
Myr

[fish] Make widgets work with --option= prefix (#2383)

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

authored by Jannik Vieten · committed by GitHub · parent cbfbb49 · Browse files · 1 file+13 added−2 removed
This commit

State

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

Trailers

  • Co-authored-by: Junegunn Choi <junegunn.c@gmail.com>

Diff stats

1 file+13 added−2 removed

  • other:+13 added−2 removed

1 file+13 added−2 removed

modified:shell/key-bindings.fish+13 added-2 removed
18 unmodified lines
19 function fzf-file-widget -d "List files and folders"20 set -l commandline (__fzf_parse_commandline)21 set -l dir $commandline[1]22 set -l fzf_query $commandline[2]23 set -l prefix $commandline[3]2425 # "-path \$dir'*/\\.*'" matches hidden files/folders inside $dir but not26 # $dir itself, even if hidden.27 test -n "$FZF_CTRL_T_COMMAND"; or set -l FZF_CTRL_T_COMMAND "
14 unmodified lines
42 # Remove last token from commandline.43 commandline -t ""44 end45 for i in $result46 commandline -it -- $prefix47 commandline -it -- (string escape $i)48 commandline -it -- ' '49 end50 commandline -f repaint
24 unmodified lines
75 function fzf-cd-widget -d "Change directory"76 set -l commandline (__fzf_parse_commandline)77 set -l dir $commandline[1]78 set -l fzf_query $commandline[2]79 set -l prefix $commandline[3]8081 test -n "$FZF_ALT_C_COMMAND"; or set -l FZF_ALT_C_COMMAND "82 command find -L \$dir -mindepth 1 \\( -path \$dir'*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' \\) -prune \83 -o -type d -print 2> /dev/null | sed 's@^\./@@'"
6 unmodified lines
90 cd $result9192 # Remove last token from commandline.93 commandline -t ""94 commandline -it -- $prefix95 end96 end9798 commandline -f repaint
20 unmodified lines
119 bind -M insert \cr fzf-history-widget120 bind -M insert \ec fzf-cd-widget121 end122119 function __fzf_parse_commandline -d 'Parse the current command line token and return split of existing filepath and rest of token'123 function __fzf_parse_commandline -d 'Parse the current command line token and return split of existing filepath, fzf query, and optional -option= prefix'124 set -l commandline (commandline -t)125126 # strip -option= from token if present127 set -l prefix (string match -r -- '^-[^\s=]+=' $commandline)128 set commandline (string replace -- "$prefix" '' $commandline)129130 # eval is used to do shell expansion on paths121 set -l commandline (eval "printf '%s' "(commandline -t))131 eval set commandline $commandline132133 if [ -z $commandline ]134 # Default to current directory with no --query135 set dir '.'
11 unmodified lines
147 end148149 echo $dir150 echo $fzf_query151 echo $prefix152 end153154 function __fzf_get_dir -d 'Find the longest existing filepath from input string'155 set dir $argv
17 unmodified lines