aboutsummaryrefslogtreecommitdiffstats
path: root/commands/ct.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/ct.go')
-rw-r--r--commands/ct.go27
1 files changed, 23 insertions, 4 deletions
diff --git a/commands/ct.go b/commands/ct.go
index 19fb63aa..4e66331c 100644
--- a/commands/ct.go
+++ b/commands/ct.go
@@ -3,6 +3,7 @@ package commands
import (
"errors"
"fmt"
+ "strconv"
"strings"
"git.sr.ht/~sircmpwn/aerc/widgets"
@@ -35,16 +36,34 @@ func (_ ChangeTab) Execute(aerc *widgets.Aerc, args []string) error {
if len(args) != 2 {
return errors.New(fmt.Sprintf("Usage: %s <tab>", args[0]))
}
-
if args[1] == "-" {
ok := aerc.SelectPreviousTab()
if !ok {
return errors.New("No previous tab to return to")
}
} else {
- ok := aerc.SelectTab(args[1])
- if !ok {
- return errors.New("No tab with that name")
+ n, err := strconv.Atoi(args[1])
+ if err == nil {
+ if strings.HasPrefix(args[1], "+") {
+ for ; n > 0; n-- {
+ aerc.NextTab()
+ }
+ } else if strings.HasPrefix(args[1], "-") {
+ for ; n < 0; n++ {
+ aerc.PrevTab()
+ }
+ } else {
+ ok := aerc.SelectTabIndex(n)
+ if !ok {
+ return errors.New(
+ "No tab with that index")
+ }
+ }
+ } else {
+ ok := aerc.SelectTab(args[1])
+ if !ok {
+ return errors.New("No tab with that name")
+ }
}
}
return nil