Skip to content

Commit 9911acd

Browse files
committed
Start terminal in configurable directory
1 parent 98ad66d commit 9911acd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

pkg/terminal/terminal.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
// Terminal communicates with the underlying terminal which is running shox
2020
type Terminal struct {
2121
shell string
22+
dir string
2223
proxy *proxy.Proxy
2324
pty *os.File
2425
enableNesting bool
@@ -43,6 +44,11 @@ func (t *Terminal) SetShell(shell string) {
4344
t.shell = shell
4445
}
4546

47+
// SetDir sets the directory the shell will start in (CWD)
48+
func (t *Terminal) SetDir(dir string) {
49+
t.dir = dir
50+
}
51+
4652
// AddDecorator adds a decorator to alter the terminal output
4753
func (t *Terminal) AddDecorator(d decorators.Decorator) {
4854
t.proxy.AddDecorator(d)
@@ -75,6 +81,10 @@ func (t *Terminal) Run() error {
7581
// Create arbitrary command.
7682
c := exec.Command(t.shell)
7783

84+
if t.dir != "" {
85+
c.Dir = t.dir
86+
}
87+
7888
// Start the command with a pty.
7989
var err error
8090
t.pty, err = pty.Start(c)

0 commit comments

Comments
 (0)