Allow no arguments to :cd
I often use the bare `cd` command to get back to my home directory.
This commit is contained in:
parent
eabdcff863
commit
023a2622f9
1 changed files with 5 additions and 3 deletions
|
@ -17,15 +17,17 @@ func init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func ChangeDirectory(aerc *widgets.Aerc, args []string) error {
|
func ChangeDirectory(aerc *widgets.Aerc, args []string) error {
|
||||||
if len(args) != 2 {
|
if len(args) < 1 || len(args) > 2 {
|
||||||
return errors.New("Usage: cd <directory>")
|
return errors.New("Usage: cd [directory]")
|
||||||
}
|
}
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var target string
|
var target string
|
||||||
if args[1] == "-" {
|
if len(args) == 1 {
|
||||||
|
target = "~"
|
||||||
|
} else if args[1] == "-" {
|
||||||
if previousDir == "" {
|
if previousDir == "" {
|
||||||
return errors.New("No previous folder to return to")
|
return errors.New("No previous folder to return to")
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue