File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff 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)
5056func (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 (" \033 c" )) // reset term
91+ t .proxy .Write ([]byte (fmt . Sprintf ( " \x1b c%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+ }
You can’t perform that action at this time.
0 commit comments