aboutsummaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-17 17:08:54 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-17 17:08:54 -0400
commit16c3f0a89309541e36a2de22e91176fd13c67898 (patch)
tree23c5946f4f56256a07a512d7c49a89c675c8ca0b /commands
parent14cb8cb51f4a1dfca2486d154e2206b19f9401a7 (diff)
Handle terminal title, login shell
Diffstat (limited to 'commands')
-rw-r--r--commands/term.go21
1 files changed, 16 insertions, 5 deletions
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 [<command>]")
+ 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
}