From 80ab2e4fc42d4ff89454d96fa37fae73df58d6d1 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sat, 18 May 2019 17:51:32 +0300 Subject: [PATCH] cd if first argument is a directory Related #167 --- app.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app.go b/app.go index b59e9e7..c3d1ded 100644 --- a/app.go +++ b/app.go @@ -137,7 +137,14 @@ func (app *app) loop() { if gSelect != "" { go func() { - app.ui.exprChan <- &callExpr{"select", []string{gSelect}, 1} + stat, err := os.Stat(gSelect) + if err != nil { + app.ui.exprChan <- &callExpr{"echoerr", []string{err.Error()}, 1} + } else if stat.IsDir() { + app.ui.exprChan <- &callExpr{"cd", []string{gSelect}, 1} + } else { + app.ui.exprChan <- &callExpr{"select", []string{gSelect}, 1} + } }() }