From 023a2622f98da1b5b0b59696db33939d7f358e87 Mon Sep 17 00:00:00 2001 From: Tadeo Kondrak Date: Wed, 5 Jun 2019 00:58:40 -0600 Subject: Allow no arguments to :cd I often use the bare `cd` command to get back to my home directory. --- commands/cd.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'commands') diff --git a/commands/cd.go b/commands/cd.go index 3da1555..fb495d7 100644 --- a/commands/cd.go +++ b/commands/cd.go @@ -17,15 +17,17 @@ func init() { } func ChangeDirectory(aerc *widgets.Aerc, args []string) error { - if len(args) != 2 { - return errors.New("Usage: cd ") + if len(args) < 1 || len(args) > 2 { + return errors.New("Usage: cd [directory]") } cwd, err := os.Getwd() if err != nil { return err } var target string - if args[1] == "-" { + if len(args) == 1 { + target = "~" + } else if args[1] == "-" { if previousDir == "" { return errors.New("No previous folder to return to") } else { -- cgit v1.2.3