Merge branch 'master' of github.com:ivaaaan/smug

This commit is contained in:
Ivan Klymenchenko 2021-02-01 23:49:44 +02:00
commit 00096ca320
3 changed files with 9 additions and 5 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"os"
"os/exec"
"path/filepath"
@ -137,13 +138,14 @@ func (smug Smug) Start(config Config, options Options, context Context) error {
return err
}
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)
target := fmt.Sprintf("%s.%d", window, pIndex)
newPane, err := smug.tmux.SplitWindow(target, p.Type, paneRoot)
if err != nil {
return err
}

View File

@ -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 -t ses:win1 -c root -F #{pane_id} -h",
"tmux split-window -Pd -h -t ses:win1.0 -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 -t ses:win1 -c root/win1/pane1 -F #{pane_id} -v",
"tmux split-window -Pd -v -t ses:win1.0 -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:",

View File

@ -67,7 +67,7 @@ func (tmux Tmux) RenumberWindows(target string) error {
}
func (tmux Tmux) SplitWindow(target string, splitType string, root string) (string, error) {
args := []string{"split-window", "-Pd", "-t", target, "-c", root, "-F", "#{pane_id}"}
args := []string{"split-window", "-Pd"}
switch splitType {
case VSplit:
@ -76,6 +76,8 @@ func (tmux Tmux) SplitWindow(target string, splitType string, root string) (stri
args = append(args, "-h")
}
args = append(args, []string{"-t", target, "-c", root, "-F", "#{pane_id}"}...)
cmd := exec.Command("tmux", args...)
pane, err := tmux.commander.Exec(cmd)