Skip to content
Myr

Allow comments in $FZF_DEFAULT_OPTS and $FZF_DEFAULT_OPTS_FILE

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

Close #3961

authored by Junegunn Choi · committed by Junegunn Choi · parent e28f5aa · Browse files · 4 files+22 added−7 removed
This commit

State

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

Diff stats

4 files+22 added−7 removed

  • other:+22 added−7 removed

4 files+22 added−7 removed

modified:src/options.go+9 added-3 removed
10 unmodified lines
1112 "github.com/junegunn/fzf/src/algo"13 "github.com/junegunn/fzf/src/tui"1415 "github.com/mattn/go-shellwords"15 "github.com/junegunn/go-shellwords"16 "github.com/rivo/uniseg"17)1819const Usage = `fzf is an interactive filter program for any kind of list.
2894 unmodified lines
29142915 return processScheme(opts)2916}29172918func parseShellWords(str string) ([]string, error) {2919 parser := shellwords.NewParser()2920 parser.ParseComment = true2921 return parser.Parse(str)2922}29232924// ParseOptions parses command-line options2925func ParseOptions(useDefaults bool, args []string) (*Options, error) {2926 opts := defaultOptions()2927 index := 0
5 unmodified lines
2933 if err != nil {2934 return nil, errors.New("$FZF_DEFAULT_OPTS_FILE: " + err.Error())2935 }29362931 words, parseErr := shellwords.Parse(string(bytes))2937 words, parseErr := parseShellWords(string(bytes))2938 if parseErr != nil {2939 return nil, errors.New(path + ": " + parseErr.Error())2940 }2941 if len(words) > 0 {
3 unmodified lines
2945 }2946 }29472948 // 2. Options from $FZF_DEFAULT_OPTS string2943 words, parseErr := shellwords.Parse(os.Getenv("FZF_DEFAULT_OPTS"))2949 words, parseErr := parseShellWords(os.Getenv("FZF_DEFAULT_OPTS"))2950 if parseErr != nil {2951 return nil, errors.New("$FZF_DEFAULT_OPTS: " + parseErr.Error())2952 }2953 if len(words) > 0 {
34 unmodified lines
modified:CHANGELOG.md+10 added-1 removed
1CHANGELOG2=========340.54.440.55.05------6- [bash] Fuzzy path completion is enabled for all commands7 - 1. If the default completion is not already set8 - 2. And if the current bash supports `complete -D` option9 - However, fuzzy completion for some commands can be "dynamically" disabled by the dynamic completion loader10 - See the comment in `__fzf_default_completion` function for more information11- Comments are now allowed in `$FZF_DEFAULT_OPTS` and `$FZF_DEFAULT_OPTS_FILE`12 ```sh13 export FZF_DEFAULT_OPTS='14 # Layout options15 --layout=reverse16 --info=inline-right # Show info on the right side of the prompt line17 # ...18 '19 ```20- Fixed `--tmux bottom` when the status line is not at the bottom21- Fixed extra scroll offset in multi-line mode (`--read0` or `--wrap`)22- Added fallback `ps` command for `kill` completion on Cygwin23
2240 unmodified lines
modified:go.mod+1 added-1 removed
1 unmodified line
23require (4 github.com/charlievieth/fastwalk v1.0.85 github.com/gdamore/tcell/v2 v2.7.46 github.com/junegunn/go-shellwords v0.0.0-20240813092932-a62c48c52e977 github.com/mattn/go-isatty v0.0.207 github.com/mattn/go-shellwords v1.0.128 github.com/rivo/uniseg v0.4.79 golang.org/x/sys v0.22.010 golang.org/x/term v0.22.011)
9 unmodified lines
modified:go.sum+2 added-2 removed
2 unmodified lines
3github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=4github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=5github.com/gdamore/tcell/v2 v2.7.4 h1:sg6/UnTM9jGpZU+oFYAsDahfchWAFW8Xx2yFinNSAYU=6github.com/gdamore/tcell/v2 v2.7.4/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg=7github.com/junegunn/go-shellwords v0.0.0-20240813092932-a62c48c52e97 h1:rqzLixVo1c/GQW6px9j1xQmlvQIn+lf/V6M1UQ7IFzw=8github.com/junegunn/go-shellwords v0.0.0-20240813092932-a62c48c52e97/go.mod h1:6EILKtGpo5t+KLb85LNZLAF6P9LKp78hJI80PXMcn3c=9github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=10github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=11github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=12github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=13github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=14github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=13github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=14github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=15github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=16github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=17github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=18github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
39 unmodified lines