Skip to content

Commit 7067f9a

Browse files
committed
Add motd option
1 parent d364d53 commit 7067f9a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/terminal/terminal.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ type Terminal struct {
2424
pty *os.File
2525
enableNesting bool
2626
hideOutput bool
27-
outputMutex sync.RWMutex
27+
outputMutex sync.RWMutex
28+
motd string
2829
}
2930

3031
// NewTerminal creates a new terminal instance
@@ -46,6 +47,11 @@ func (t *Terminal) SetShell(shell string) {
4647
t.shell = shell
4748
}
4849

50+
// SetMOTD sets the motd to write to the terminal before the main command is launched
51+
func (t *Terminal) SetMOTD(motd string) {
52+
t.motd = motd
53+
}
54+
4955
// SetDir sets the directory the shell will start in (CWD)
5056
func (t *Terminal) SetDir(dir string) {
5157
t.dir = dir
@@ -82,7 +88,7 @@ func (t *Terminal) Run() error {
8288

8389
t.proxy.Start()
8490
defer t.proxy.Close()
85-
t.proxy.Write([]byte("\033c")) // reset term
91+
t.proxy.Write([]byte(fmt.Sprintf("\x1bc%s", t.motd))) // reset term and write motd
8692

8793
// Create arbitrary command.
8894
c := exec.Command(t.shell)
@@ -155,4 +161,4 @@ func (t *Terminal) hideAllOutput() bool {
155161
t.outputMutex.RLock()
156162
defer t.outputMutex.RUnlock()
157163
return t.hideOutput
158-
}
164+
}

0 commit comments

Comments
 (0)