Skip to content

Commit

Permalink
Add motd option
Browse files Browse the repository at this point in the history
  • Loading branch information
liamg committed Jul 29, 2020
1 parent d364d53 commit 7067f9a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/terminal/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ type Terminal struct {
pty *os.File
enableNesting bool
hideOutput bool
outputMutex sync.RWMutex
outputMutex sync.RWMutex
motd string
}

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

// SetMOTD sets the motd to write to the terminal before the main command is launched
func (t *Terminal) SetMOTD(motd string) {
t.motd = motd
}

// SetDir sets the directory the shell will start in (CWD)
func (t *Terminal) SetDir(dir string) {
t.dir = dir
Expand Down Expand Up @@ -82,7 +88,7 @@ func (t *Terminal) Run() error {

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

// Create arbitrary command.
c := exec.Command(t.shell)
Expand Down Expand Up @@ -155,4 +161,4 @@ func (t *Terminal) hideAllOutput() bool {
t.outputMutex.RLock()
defer t.outputMutex.RUnlock()
return t.hideOutput
}
}

0 comments on commit 7067f9a

Please sign in to comment.