about summary refs log tree commit diff stats
path: root/commands/cd.go
diff options
context:
space:
mode:
authorTadeo Kondrak <me@tadeo.ca>2019-06-05 00:58:40 -0600
committerDrew DeVault <sir@cmpwn.com>2019-06-05 09:32:23 -0400
commit023a2622f98da1b5b0b59696db33939d7f358e87 (patch)
tree3d77050b25314a954d9e1bb953e68a8ae44de28d /commands/cd.go
parenteabdcff8632fbb42ea75285d0c88add316db5c30 (diff)
downloadaerc-023a2622f98da1b5b0b59696db33939d7f358e87.tar.gz
Allow no arguments to :cd
I often use the bare `cd` command to get back to my home directory.
Diffstat (limited to 'commands/cd.go')
-rw-r--r--commands/cd.go8
1 files changed, 5 insertions, 3 deletions
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 <directory>")
+	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 {
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198