From 9720b5f4bcf2dd888973b91c3984187c5015ec20 Mon Sep 17 00:00:00 2001 From: verse91 Date: Mon, 4 May 2026 20:15:44 +0700 Subject: [PATCH] fix(filegen): cd and zoxide only shows dir --- commands/core/filegen.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/commands/core/filegen.go b/commands/core/filegen.go index 60d772c..fd68b28 100644 --- a/commands/core/filegen.go +++ b/commands/core/filegen.go @@ -52,7 +52,16 @@ func FileGenerator(filters ...string) GeneratorFunc { // check if the partial string contains path separators if i := strings.LastIndexAny(partial, "/\\"); i != -1 { - dir = filepath.Join(base, partial[:i+1]) + pathDir := partial[:i+1] + if filepath.IsAbs(pathDir) || strings.HasPrefix(pathDir, "~") { + if strings.HasPrefix(pathDir, "~") { + home, _ := os.UserHomeDir() + pathDir = filepath.Join(home, pathDir[1:]) + } + dir = pathDir + } else { + dir = filepath.Join(base, pathDir) + } filePrefix = partial[i+1:] } @@ -112,6 +121,11 @@ func FileGenerator(filters ...string) GeneratorFunc { } continue } + + if dirOnly { + continue + } + // if filters are set, only show matching extensions if len(filterSet) > 0 { ext := strings.ToLower(filepath.Ext(name))