mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-22 04:45:14 +00:00
Allow comments in $FZF_DEFAULT_OPTS and $FZF_DEFAULT_OPTS_FILE
Close #3961
This commit is contained in:
parent
e28f5aa45b
commit
e215e2daf3
11
CHANGELOG.md
11
CHANGELOG.md
@ -1,13 +1,22 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
0.54.4
|
0.55.0
|
||||||
------
|
------
|
||||||
- [bash] Fuzzy path completion is enabled for all commands
|
- [bash] Fuzzy path completion is enabled for all commands
|
||||||
- 1. If the default completion is not already set
|
- 1. If the default completion is not already set
|
||||||
- 2. And if the current bash supports `complete -D` option
|
- 2. And if the current bash supports `complete -D` option
|
||||||
- However, fuzzy completion for some commands can be "dynamically" disabled by the dynamic completion loader
|
- However, fuzzy completion for some commands can be "dynamically" disabled by the dynamic completion loader
|
||||||
- See the comment in `__fzf_default_completion` function for more information
|
- See the comment in `__fzf_default_completion` function for more information
|
||||||
|
- Comments are now allowed in `$FZF_DEFAULT_OPTS` and `$FZF_DEFAULT_OPTS_FILE`
|
||||||
|
```sh
|
||||||
|
export FZF_DEFAULT_OPTS='
|
||||||
|
# Layout options
|
||||||
|
--layout=reverse
|
||||||
|
--info=inline-right # Show info on the right side of the prompt line
|
||||||
|
# ...
|
||||||
|
'
|
||||||
|
```
|
||||||
- Fixed `--tmux bottom` when the status line is not at the bottom
|
- Fixed `--tmux bottom` when the status line is not at the bottom
|
||||||
- Fixed extra scroll offset in multi-line mode (`--read0` or `--wrap`)
|
- Fixed extra scroll offset in multi-line mode (`--read0` or `--wrap`)
|
||||||
- Added fallback `ps` command for `kill` completion on Cygwin
|
- Added fallback `ps` command for `kill` completion on Cygwin
|
||||||
|
2
go.mod
2
go.mod
@ -3,8 +3,8 @@ module github.com/junegunn/fzf
|
|||||||
require (
|
require (
|
||||||
github.com/charlievieth/fastwalk v1.0.8
|
github.com/charlievieth/fastwalk v1.0.8
|
||||||
github.com/gdamore/tcell/v2 v2.7.4
|
github.com/gdamore/tcell/v2 v2.7.4
|
||||||
|
github.com/junegunn/go-shellwords v0.0.0-20240813092932-a62c48c52e97
|
||||||
github.com/mattn/go-isatty v0.0.20
|
github.com/mattn/go-isatty v0.0.20
|
||||||
github.com/mattn/go-shellwords v1.0.12
|
|
||||||
github.com/rivo/uniseg v0.4.7
|
github.com/rivo/uniseg v0.4.7
|
||||||
golang.org/x/sys v0.22.0
|
golang.org/x/sys v0.22.0
|
||||||
golang.org/x/term v0.22.0
|
golang.org/x/term v0.22.0
|
||||||
|
4
go.sum
4
go.sum
@ -4,14 +4,14 @@ github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdk
|
|||||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||||
github.com/gdamore/tcell/v2 v2.7.4 h1:sg6/UnTM9jGpZU+oFYAsDahfchWAFW8Xx2yFinNSAYU=
|
github.com/gdamore/tcell/v2 v2.7.4 h1:sg6/UnTM9jGpZU+oFYAsDahfchWAFW8Xx2yFinNSAYU=
|
||||||
github.com/gdamore/tcell/v2 v2.7.4/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg=
|
github.com/gdamore/tcell/v2 v2.7.4/go.mod h1:dSXtXTSK0VsW1biw65DZLZ2NKr7j0qP/0J7ONmsraWg=
|
||||||
|
github.com/junegunn/go-shellwords v0.0.0-20240813092932-a62c48c52e97 h1:rqzLixVo1c/GQW6px9j1xQmlvQIn+lf/V6M1UQ7IFzw=
|
||||||
|
github.com/junegunn/go-shellwords v0.0.0-20240813092932-a62c48c52e97/go.mod h1:6EILKtGpo5t+KLb85LNZLAF6P9LKp78hJI80PXMcn3c=
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||||
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
github.com/mattn/go-shellwords v1.0.12 h1:M2zGm7EW6UQJvDeQxo4T51eKPurbeFbe8WtebGE2xrk=
|
|
||||||
github.com/mattn/go-shellwords v1.0.12/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
|
|
||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
|
@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/junegunn/fzf/src/algo"
|
"github.com/junegunn/fzf/src/algo"
|
||||||
"github.com/junegunn/fzf/src/tui"
|
"github.com/junegunn/fzf/src/tui"
|
||||||
|
|
||||||
"github.com/mattn/go-shellwords"
|
"github.com/junegunn/go-shellwords"
|
||||||
"github.com/rivo/uniseg"
|
"github.com/rivo/uniseg"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -2915,6 +2915,12 @@ func postProcessOptions(opts *Options) error {
|
|||||||
return processScheme(opts)
|
return processScheme(opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseShellWords(str string) ([]string, error) {
|
||||||
|
parser := shellwords.NewParser()
|
||||||
|
parser.ParseComment = true
|
||||||
|
return parser.Parse(str)
|
||||||
|
}
|
||||||
|
|
||||||
// ParseOptions parses command-line options
|
// ParseOptions parses command-line options
|
||||||
func ParseOptions(useDefaults bool, args []string) (*Options, error) {
|
func ParseOptions(useDefaults bool, args []string) (*Options, error) {
|
||||||
opts := defaultOptions()
|
opts := defaultOptions()
|
||||||
@ -2928,7 +2934,7 @@ func ParseOptions(useDefaults bool, args []string) (*Options, error) {
|
|||||||
return nil, errors.New("$FZF_DEFAULT_OPTS_FILE: " + err.Error())
|
return nil, errors.New("$FZF_DEFAULT_OPTS_FILE: " + err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
words, parseErr := shellwords.Parse(string(bytes))
|
words, parseErr := parseShellWords(string(bytes))
|
||||||
if parseErr != nil {
|
if parseErr != nil {
|
||||||
return nil, errors.New(path + ": " + parseErr.Error())
|
return nil, errors.New(path + ": " + parseErr.Error())
|
||||||
}
|
}
|
||||||
@ -2940,7 +2946,7 @@ func ParseOptions(useDefaults bool, args []string) (*Options, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 2. Options from $FZF_DEFAULT_OPTS string
|
// 2. Options from $FZF_DEFAULT_OPTS string
|
||||||
words, parseErr := shellwords.Parse(os.Getenv("FZF_DEFAULT_OPTS"))
|
words, parseErr := parseShellWords(os.Getenv("FZF_DEFAULT_OPTS"))
|
||||||
if parseErr != nil {
|
if parseErr != nil {
|
||||||
return nil, errors.New("$FZF_DEFAULT_OPTS: " + parseErr.Error())
|
return nil, errors.New("$FZF_DEFAULT_OPTS: " + parseErr.Error())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user