diff --git a/smug.go b/smug.go index f0589fc..821124c 100644 --- a/smug.go +++ b/smug.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "os/exec" "path/filepath" @@ -138,18 +137,20 @@ func (smug Smug) Start(config Config, options Options, context Context) error { return err } - for pIndex, p := range w.Panes { + var lastPane string + for _, p := range w.Panes { paneRoot := ExpandPath(p.Root) if paneRoot == "" || !filepath.IsAbs(p.Root) { paneRoot = filepath.Join(windowRoot, p.Root) } - target := fmt.Sprintf("%s.%d", window, pIndex) - newPane, err := smug.tmux.SplitWindow(target, p.Type, paneRoot) + newPane, err := smug.tmux.SplitWindow(window+"."+lastPane, p.Type, paneRoot) if err != nil { return err } + lastPane = newPane + for _, c := range p.Commands { err = smug.tmux.SendKeys(window+"."+newPane, c) if err != nil { diff --git a/smug_test.go b/smug_test.go index f52408d..32dc3f9 100644 --- a/smug_test.go +++ b/smug_test.go @@ -79,7 +79,7 @@ var testTable = []struct { "tmux new -Pd -s ses -n smug_def -c root", "tmux neww -Pd -t ses: -n win1 -c root", "tmux select-layout -t ses:win1 main-horizontal", - "tmux split-window -Pd -h -t ses:win1.0 -c root -F #{pane_id}", + "tmux split-window -Pd -h -t ses:win1. -c root -F #{pane_id}", "tmux kill-window -t ses:smug_def", "tmux move-window -r -s ses: -t ses:", "tmux attach -d -t ses:win1", @@ -192,7 +192,7 @@ var testTable = []struct { "tmux new -Pd -s ses -n smug_def -c root", "tmux neww -Pd -t ses: -n win1 -c root/win1", "tmux select-layout -t ses:win1 even-horizontal", - "tmux split-window -Pd -v -t ses:win1.0 -c root/win1/pane1 -F #{pane_id}", + "tmux split-window -Pd -v -t ses:win1. -c root/win1/pane1 -F #{pane_id}", "tmux send-keys -t ses:win1.1 command1 Enter", "tmux kill-window -t ses:smug_def", "tmux move-window -r -s ses: -t ses:",