summaryrefslogtreecommitdiff
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
parenteabdcff8632fbb42ea75285d0c88add316db5c30 (diff)
downloadaerc-023a2622f98da1b5b0b59696db33939d7f358e87.zip
Allow no arguments to :cd
I often use the bare `cd` command to get back to my home directory.
-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 {