blob: 70a3b2786614f4cef18fc8254de36403d9602ef6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// SPDX-FileCopyrightText: 2021 Stefan Majewsky <majewsky@gmx.net>
// SPDX-License-Identifier: GPL-3.0-only
package prompt
import (
"fmt"
"io"
)
//TerminalTitle contains all pieces that go into the terminal title.
type TerminalTitle struct {
HostName string
Path string
}
//PrintTo produces the VT command that sets the terminal title.
func (t TerminalTitle) PrintTo(stdout io.Writer) {
//warn about missing pieces
if t.HostName == "" {
t.HostName = "N/A"
}
if t.Path == "" {
t.Path = "N/A"
}
fmt.Fprintf(stdout, "\x1B]0;\u23A3%s\u23A6 %s\x07", t.HostName, t.Path)
}
|