~adnano/astronaut

61c818ea851e13b63fdec2c380b2f94d05734c02 — Adnan Maolood 5 months ago c854ee4
command: Allow selecting tabs by number
1 files changed, 10 insertions(+), 1 deletions(-)

M command.go
M command.go => command.go +10 -1
@@ 149,13 149,22 @@ func cmdClose(b *Browser, args ...string) error {

func cmdTab(b *Browser, args ...string) error {
	if len(args) == 0 {
		return errors.New("usage: tab prev|next")
		return errors.New("usage: tab prev|next|<n>")
	}
	switch args[0] {
	case "prev":
		b.Previous()
	case "next":
		b.Next()
	default:
		n, err := strconv.Atoi(args[0])
		if err != nil {
			return err
		}
		if n >= 1 && n <= len(b.tabs) {
			b.tab = n - 1
		}
		b.view.Invalidate()
	}
	return nil
}