diff --git a/pkg/terminal/terminal.go b/pkg/terminal/terminal.go index 10fd661..75faa29 100644 --- a/pkg/terminal/terminal.go +++ b/pkg/terminal/terminal.go @@ -18,9 +18,10 @@ import ( // Terminal communicates with the underlying terminal which is running shox type Terminal struct { - shell string - proxy *proxy.Proxy - pty *os.File + shell string + proxy *proxy.Proxy + pty *os.File + enableNesting bool } // NewTerminal creates a new terminal instance @@ -52,15 +53,21 @@ func (t *Terminal) Pty() *os.File { return t.pty } +// SetNestingAllowed sets whether multiple shox bars can be nested inside each other +func (t *Terminal) SetNestingAllowed(allowed bool) { + t.enableNesting = allowed +} + // Run starts the terminal/shell proxying process func (t *Terminal) Run() error { - if os.Getenv("SHOX") != "" { - return fmt.Errorf("shox is already running in this terminal") + if !t.enableNesting { + if os.Getenv("SHOX") != "" { + return fmt.Errorf("shox is already running in this terminal") + } + _ = os.Setenv("SHOX", "1") } - _ = os.Setenv("SHOX", "1") - t.proxy.Start() defer t.proxy.Close() t.proxy.Write([]byte("\033c")) // reset term