|
|
|
@ -9,6 +9,11 @@ import (
|
|
|
|
|
|
|
|
|
|
const defaultWindowName = "smug_def"
|
|
|
|
|
|
|
|
|
|
// Very wisely picked default value,
|
|
|
|
|
// after which panes will be rebalanced for each `split-window`
|
|
|
|
|
// Helps with "no space for new pane" error
|
|
|
|
|
const defaultRebalancePanesThreshold = 5
|
|
|
|
|
|
|
|
|
|
func ExpandPath(path string) string {
|
|
|
|
|
if strings.HasPrefix(path, "~/") {
|
|
|
|
|
userHome, err := os.UserHomeDir()
|
|
|
|
@ -90,6 +95,11 @@ func (smug Smug) Start(config Config, options Options, context Context) error {
|
|
|
|
|
windows := options.Windows
|
|
|
|
|
attach := options.Attach
|
|
|
|
|
|
|
|
|
|
rebalancePanesThreshold := config.RebalanceWindowsThreshold
|
|
|
|
|
if rebalancePanesThreshold == 0 {
|
|
|
|
|
rebalancePanesThreshold = defaultRebalancePanesThreshold
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !sessionExists {
|
|
|
|
|
err := smug.execShellCommands(config.BeforeStart, sessionRoot)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -126,13 +136,14 @@ func (smug Smug) Start(config Config, options Options, context Context) error {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for _, p := range w.Panes {
|
|
|
|
|
for pIndex, p := range w.Panes {
|
|
|
|
|
paneRoot := ExpandPath(p.Root)
|
|
|
|
|
if paneRoot == "" || !filepath.IsAbs(p.Root) {
|
|
|
|
|
paneRoot = filepath.Join(windowRoot, p.Root)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newPane, err := smug.tmux.SplitWindow(window, p.Type, paneRoot)
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
@ -143,6 +154,14 @@ func (smug Smug) Start(config Config, options Options, context Context) error {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if pIndex+1 >= rebalancePanesThreshold {
|
|
|
|
|
_, err = smug.tmux.SelectLayout(window, Tiled)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layout := w.Layout
|
|
|
|
|