diff --git a/README.md b/README.md index e187153..c4f3b68 100644 --- a/README.md +++ b/README.md @@ -589,6 +589,7 @@ Available fields: | `startup_command` | Command to run on session creation (supports `{}` for path) | | `preview_command` | Command to run when previewing the session | | `disable_startup_command` | Set to `true` to suppress the startup command | +| `windows` | Window layout to use (array of window names from `[[window]]` configs) | **Note:** Patterns use Go's `filepath.Match` syntax which supports `*` (any sequence), `?` (single character), and `[...]` (character classes). Recursive matching with `**` is not supported -- `~/projects/*` matches `~/projects/foo` but not `~/projects/foo/bar`. Explicit `[[session]]` configs always take priority over wildcard matches. If multiple wildcards match, the first one in config order wins. diff --git a/connector/config_wildcard.go b/connector/config_wildcard.go index bf665a5..558c9ec 100644 --- a/connector/config_wildcard.go +++ b/connector/config_wildcard.go @@ -5,7 +5,7 @@ import ( ) func configWildcardStrategy(c *RealConnector, name string) (model.Connection, error) { - _, found := c.lister.FindConfigWildcard(name) + wc, found := c.lister.FindConfigWildcard(name) if !found { return model.Connection{Found: false}, nil } @@ -30,9 +30,11 @@ func configWildcardStrategy(c *RealConnector, name string) (model.Connection, er New: true, AddToZoxide: true, Session: model.SeshSession{ - Src: "config_wildcard", - Name: nameFromPath, - Path: absPath, + Src: "config_wildcard", + Name: nameFromPath, + Path: absPath, + WindowNames: wc.Windows, + DisableStartupCommand: wc.DisableStartCommand, }, }, nil } diff --git a/connector/config_wildcard_test.go b/connector/config_wildcard_test.go index 855c17e..852b04f 100644 --- a/connector/config_wildcard_test.go +++ b/connector/config_wildcard_test.go @@ -41,6 +41,7 @@ func TestConfigWildcardStrategy(t *testing.T) { mockLister.On("FindConfigWildcard", "~/projects/myapp").Return(model.WildcardConfig{ Pattern: "~/projects/*", StartupCommand: "nvim", + Windows: []string{"code", "server"}, }, true) mockHome.On("ExpandHome", "~/projects/myapp").Return("/Users/test/projects/myapp", nil) mockDir.On("Dir", "/Users/test/projects/myapp").Return(true, "/Users/test/projects/myapp") @@ -54,6 +55,22 @@ func TestConfigWildcardStrategy(t *testing.T) { assert.Equal(t, "myapp", connection.Session.Name) assert.Equal(t, "/Users/test/projects/myapp", connection.Session.Path) assert.Equal(t, "config_wildcard", connection.Session.Src) + assert.Equal(t, []string{"code", "server"}, connection.Session.WindowNames) + }) + + t.Run("should propagate DisableStartupCommand from wildcard config", func(t *testing.T) { + mockLister.On("FindConfigWildcard", "~/projects/quiet").Return(model.WildcardConfig{ + Pattern: "~/projects/*", + DisableStartCommand: true, + }, true) + mockHome.On("ExpandHome", "~/projects/quiet").Return("/Users/test/projects/quiet", nil) + mockDir.On("Dir", "/Users/test/projects/quiet").Return(true, "/Users/test/projects/quiet") + mockNamer.On("Name", "/Users/test/projects/quiet").Return("quiet", nil) + + connection, err := configWildcardStrategy(c, "~/projects/quiet") + assert.Nil(t, err) + assert.True(t, connection.Found) + assert.True(t, connection.Session.DisableStartupCommand) }) t.Run("should return not found when no wildcard matches", func(t *testing.T) { diff --git a/model/config.go b/model/config.go index 22d5532..d26a9f9 100644 --- a/model/config.go +++ b/model/config.go @@ -42,9 +42,10 @@ type ( } WildcardConfig struct { - Pattern string `toml:"pattern"` - StartupCommand string `toml:"startup_command"` - DisableStartCommand bool `toml:"disable_startup_command"` - PreviewCommand string `toml:"preview_command"` + Pattern string `toml:"pattern"` + StartupCommand string `toml:"startup_command"` + DisableStartCommand bool `toml:"disable_startup_command"` + PreviewCommand string `toml:"preview_command"` + Windows []string `toml:"windows"` } ) diff --git a/sesh.schema.json b/sesh.schema.json index 65767e8..e64a5aa 100644 --- a/sesh.schema.json +++ b/sesh.schema.json @@ -167,6 +167,13 @@ "preview_command": { "type": "string", "description": "Command used to generate the preview for matching sessions" + }, + "windows": { + "type": "array", + "description": "Window layout to use for matching sessions", + "items": { + "type": "string" + } } }, "additionalProperties": false