aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2021-11-02 10:40:08 +0100
committerRobin Jarry <robin@jarry.cc>2021-11-02 11:24:33 +0100
commit138977b2ceef2af605f48a5ea9e44c967947561b (patch)
tree9a6d8335be4d4c00de4671c4007823f276f22d8e
parentbc48628839c656e7136540d25ad706cee4816944 (diff)
downloadaerc-138977b2ceef2af605f48a5ea9e44c967947561b.tar.gz
main: set xterm title
Signed-off-by: Robin Jarry <robin@jarry.cc>
-rw-r--r--aerc.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/aerc.go b/aerc.go
index 33acb434..6e1cb8a4 100644
--- a/aerc.go
+++ b/aerc.go
@@ -8,6 +8,7 @@ import (
"os"
"runtime/debug"
"sort"
+ "strings"
"time"
"git.sr.ht/~sircmpwn/getopt"
@@ -94,6 +95,20 @@ func usage() {
log.Fatal("Usage: aerc [-v] [mailto:...]")
}
+var termsWithStatusLine = []string{"xterm", "tmux", "screen"}
+
+func setWindowTitle() {
+ term := strings.ToLower(os.Getenv("TERM"))
+ for _, t := range termsWithStatusLine {
+ if strings.Contains(term, t) {
+ // TODO: avoid hard coding the list of terminals that
+ // have status line support.
+ os.Stderr.Write([]byte("\x1b]0;aerc\a"))
+ return
+ }
+ }
+}
+
func main() {
opts, optind, err := getopt.Getopts(os.Args, "v")
if err != nil {
@@ -190,6 +205,10 @@ func main() {
close(initDone)
+ if isatty.IsTerminal(os.Stderr.Fd()) {
+ setWindowTitle()
+ }
+
for !ui.ShouldExit() {
for aerc.Tick() {
// Continue updating our internal state