From 16c3f0a89309541e36a2de22e91176fd13c67898 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 17 Mar 2019 17:08:54 -0400 Subject: Handle terminal title, login shell --- commands/term.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'commands') diff --git a/commands/term.go b/commands/term.go index 0a2aa3b..7ce1947 100644 --- a/commands/term.go +++ b/commands/term.go @@ -1,11 +1,12 @@ package commands import ( - "errors" "os/exec" "git.sr.ht/~sircmpwn/aerc2/lib/ui" "git.sr.ht/~sircmpwn/aerc2/widgets" + + "github.com/riywo/loginshell" ) func init() { @@ -13,8 +14,12 @@ func init() { } func Term(aerc *widgets.Aerc, args []string) error { - if len(args) > 2 { - return errors.New("Usage: term []") + if len(args) == 1 { + shell, err := loginshell.Shell() + if err != nil { + return err + } + args = append(args, shell) } term, err := widgets.NewTerminal(exec.Command(args[1], args[2:]...)) if err != nil { @@ -27,7 +32,13 @@ func Term(aerc *widgets.Aerc, args []string) error { {ui.SIZE_WEIGHT, 1}, }) grid.AddChild(term).At(0, 1) - aerc.NewTab(grid, "Terminal") - // TODO: update tab name when child process changes it + tab := aerc.NewTab(grid, "Terminal") + term.OnTitle = func(title string) { + if title == "" { + title = "Terminal" + } + tab.Name = title + tab.Content.Invalidate() + } return nil } -- cgit v1.2.3