Skip to content

Commit

Permalink
Start terminal in configurable directory
Browse files Browse the repository at this point in the history
  • Loading branch information
liamg committed Feb 26, 2020
1 parent 98ad66d commit 9911acd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/terminal/terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
// Terminal communicates with the underlying terminal which is running shox
type Terminal struct {
shell string
dir string
proxy *proxy.Proxy
pty *os.File
enableNesting bool
Expand All @@ -43,6 +44,11 @@ func (t *Terminal) SetShell(shell string) {
t.shell = shell
}

// SetDir sets the directory the shell will start in (CWD)
func (t *Terminal) SetDir(dir string) {
t.dir = dir
}

// AddDecorator adds a decorator to alter the terminal output
func (t *Terminal) AddDecorator(d decorators.Decorator) {
t.proxy.AddDecorator(d)
Expand Down Expand Up @@ -75,6 +81,10 @@ func (t *Terminal) Run() error {
// Create arbitrary command.
c := exec.Command(t.shell)

if t.dir != "" {
c.Dir = t.dir
}

// Start the command with a pty.
var err error
t.pty, err = pty.Start(c)
Expand Down

0 comments on commit 9911acd

Please sign in to comment.