From 93483254c0606e6f81cfd71e0042878b51f03cbc Mon Sep 17 00:00:00 2001 From: Ivan Klymenchenko Date: Tue, 26 Jan 2021 21:38:34 +0200 Subject: [PATCH 1/3] Update version to v0.1.8 --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 7e7013e..474ff34 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,7 @@ import ( "path/filepath" ) -const version = "v0.1.7" +const version = "v0.1.8" var usage = fmt.Sprintf(`Smug - tmux session manager. Version %s From ad11231f093fbb4ccfde2db9a51850e6c0c1eaf2 Mon Sep 17 00:00:00 2001 From: Ivan Klymenchenko Date: Tue, 2 Feb 2021 00:14:49 +0200 Subject: [PATCH 2/3] Use last pane id for splitting windows --- smug.go | 9 +++++---- tmux.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) 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/tmux.go b/tmux.go index cb7a569..661359a 100644 --- a/tmux.go +++ b/tmux.go @@ -40,7 +40,7 @@ func (tmux Tmux) KillWindow(target string) error { } func (tmux Tmux) NewWindow(target string, name string, root string) (string, error) { - cmd := exec.Command("tmux", "neww", "-Pd", "-t", target, "-n", name, "-c", root) + cmd := exec.Command("tmux", "neww", "-Pd", "-t", target, "-n", name, "-c", root, "-F", "#{window_id}.#{pane_id}") return tmux.commander.Exec(cmd) } From 5e7b867bae1a4abb18213847887574ad870e6fde Mon Sep 17 00:00:00 2001 From: Ivan Klymenchenko Date: Sun, 7 Feb 2021 21:30:27 +0200 Subject: [PATCH 3/3] Fix tests --- smug_test.go | 4 ++-- tmux.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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:", diff --git a/tmux.go b/tmux.go index 661359a..cb7a569 100644 --- a/tmux.go +++ b/tmux.go @@ -40,7 +40,7 @@ func (tmux Tmux) KillWindow(target string) error { } func (tmux Tmux) NewWindow(target string, name string, root string) (string, error) { - cmd := exec.Command("tmux", "neww", "-Pd", "-t", target, "-n", name, "-c", root, "-F", "#{window_id}.#{pane_id}") + cmd := exec.Command("tmux", "neww", "-Pd", "-t", target, "-n", name, "-c", root) return tmux.commander.Exec(cmd) }