summary refs log tree commit diff stats
path: root/commands/cd.go
diff options
context:
space:
mode:
authorGalen Abell <galen@galenabell.com>2019-07-30 15:10:58 -0400
committerDrew DeVault <sir@cmpwn.com>2019-08-02 09:22:40 -0400
commitbfefafff27b126c485054c4d357e095ea2bd1147 (patch)
treeef8e6f34c21011206cf87aacdb2d65b731832cf9 /commands/cd.go
parentc4b57aaad8a48a1347a0404001fdcb13532c7620 (diff)
downloadaerc-bfefafff27b126c485054c4d357e095ea2bd1147.tar.gz
Add filesystem completions for :attach and :cd
Tab-completions now cycle through filesystem paths when using :attach or
:cd commands.
Diffstat (limited to 'commands/cd.go')
-rw-r--r--commands/cd.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/commands/cd.go b/commands/cd.go
index 8c9cb21..3630cae 100644
--- a/commands/cd.go
+++ b/commands/cd.go
@@ -3,6 +3,7 @@ package commands
 import (
 	"errors"
 	"os"
+	"strings"
 
 	"git.sr.ht/~sircmpwn/aerc/widgets"
 	"github.com/mitchellh/go-homedir"
@@ -23,7 +24,22 @@ func (_ ChangeDirectory) Aliases() []string {
 }
 
 func (_ ChangeDirectory) Complete(aerc *widgets.Aerc, args []string) []string {
-	return nil
+	path := ""
+	if len(args) >= 1 {
+		path = args[0]
+	}
+
+	completions := CompletePath(path)
+
+	var dirs []string
+	for _, c := range completions {
+		// filter out non-directories
+		if strings.HasSuffix(c, "/") {
+			dirs = append(dirs, c)
+		}
+	}
+
+	return dirs
 }
 
 func (_ ChangeDirectory) Execute(aerc *widgets.Aerc, args []string) error {