summaryrefslogtreecommitdiff
path: root/src/options.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-06-29 17:11:09 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-06-29 17:13:31 +0900
commitbf515a3d3251c54d04cd8e2e9f422cdd3f789fb8 (patch)
treec618a7ed122d2c3174165838f8b8319576513b55 /src/options.go
parenta06745826a4cba4f578a69258f9def75c59530fc (diff)
downloadfzf-bf515a3d3251c54d04cd8e2e9f422cdd3f789fb8.tar.gz
Add --walker-path-sep=CHAR to use a different path separator
This is needed when you run a Windows binary on WSL or zsh on Windows where forward slashes are expected. export FZF_DEFAULT_OPTS='--walker-path-sep /' Close #3859
Diffstat (limited to 'src/options.go')
-rw-r--r--src/options.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/options.go b/src/options.go
index d32daf10..58b5782b 100644
--- a/src/options.go
+++ b/src/options.go
@@ -147,6 +147,7 @@ Usage: fzf [options]
--walker-root=DIR Root directory from which to start walker (default: .)
--walker-skip=DIRS Comma-separated list of directory names to skip
(default: .git,node_modules)
+ --walker-path-sep=CHAR Path separator to use (default: / on Unix, \ on Windows)
Shell integration
--bash Print script to set up Bash shell integration
@@ -489,6 +490,7 @@ type Options struct {
WalkerOpts walkerOpts
WalkerRoot string
WalkerSkip []string
+ WalkerSep byte
Version bool
Help bool
CPUProfile string
@@ -592,6 +594,7 @@ func defaultOptions() *Options {
WalkerOpts: walkerOpts{file: true, hidden: true, follow: true},
WalkerRoot: ".",
WalkerSkip: []string{".git", "node_modules"},
+ WalkerSep: os.PathSeparator,
Help: false,
Version: false}
}
@@ -1904,6 +1907,14 @@ func parseMarkerMultiLine(str string) (*[3]string, error) {
return &result, nil
}
+func parsePathSep(str string) (byte, error) {
+ bytes := []byte(str)
+ if len(bytes) != 1 {
+ return os.PathSeparator, errors.New("invalid path separator (expected: single-byte character)")
+ }
+ return bytes[0], nil
+}
+
func parseOptions(index *int, opts *Options, allArgs []string) error {
var err error
var historyMax int
@@ -2479,6 +2490,14 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
return err
}
opts.WalkerSkip = filterNonEmpty(strings.Split(str, ","))
+ case "--walker-path-sep":
+ str, err := nextString(allArgs, &i, "path separator required")
+ if err != nil {
+ return err
+ }
+ if opts.WalkerSep, err = parsePathSep(str); err != nil {
+ return err
+ }
case "--profile-cpu":
if opts.CPUProfile, err = nextString(allArgs, &i, "file path required: cpu"); err != nil {
return err
@@ -2666,6 +2685,10 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
opts.WalkerRoot = value
} else if match, value := optString(arg, "--walker-skip="); match {
opts.WalkerSkip = filterNonEmpty(strings.Split(value, ","))
+ } else if match, value := optString(arg, "--walker-path-sep="); match {
+ if opts.WalkerSep, err = parsePathSep(value); err != nil {
+ return err
+ }
} else if match, value := optString(arg, "--hscroll-off="); match {
if opts.HscrollOff, err = atoi(value); err != nil {
return err