~sircmpwn/aerc

bfefafff27b126c485054c4d357e095ea2bd1147 — Galen Abell 1 year, 8 months ago c4b57aa
Add filesystem completions for :attach and :cd

Tab-completions now cycle through filesystem paths when using :attach or
:cd commands.
2 files changed, 24 insertions(+), 2 deletions(-)

M commands/cd.go
M commands/compose/attach.go
M commands/cd.go => commands/cd.go +17 -1
@@ 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 {

M commands/compose/attach.go => commands/compose/attach.go +7 -1
@@ 5,6 5,7 @@ import (
	"os"
	"time"

	"git.sr.ht/~sircmpwn/aerc/commands"
	"git.sr.ht/~sircmpwn/aerc/widgets"
	"github.com/gdamore/tcell"
	"github.com/mitchellh/go-homedir"


@@ 21,7 22,12 @@ func (_ Attach) Aliases() []string {
}

func (_ Attach) Complete(aerc *widgets.Aerc, args []string) []string {
	return nil
	path := ""
	if len(args) >= 1 {
		path = args[0]
	}

	return commands.CompletePath(path)
}

func (_ Attach) Execute(aerc *widgets.Aerc, args []string) error {