From 45da58766df1af3f3adf80440d0bd0a5ae87a3bc Mon Sep 17 00:00:00 2001 From: spike Date: Sat, 1 Oct 2022 08:52:01 +0200 Subject: [PATCH] option to start/switch silently - makes switching from within tmux seamless --- config.go | 3 ++- config_test.go | 2 ++ main.go | 13 ++++++++----- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/config.go b/config.go index b219369..4ce71d9 100644 --- a/config.go +++ b/config.go @@ -27,8 +27,9 @@ type Window struct { } type Config struct { - SendKeysTimeout int `yaml:"sendkeys_timeout"` Session string `yaml:"session"` + SendKeysTimeout int `yaml:"sendkeys_timeout"` + Silent bool `yaml:"silent"` Env map[string]string `yaml:"env"` Root string `yaml:"root"` BeforeStart []string `yaml:"before_start"` diff --git a/config_test.go b/config_test.go index b2c8f0f..bd3de1e 100644 --- a/config_test.go +++ b/config_test.go @@ -9,6 +9,7 @@ import ( func TestParseConfig(t *testing.T) { yaml := ` session: ${session} +silent: false sendkeys_timeout: 200 windows: - layout: tiled @@ -29,6 +30,7 @@ windows: expected := Config{ Session: "test", + Silent: false, SendKeysTimeout: 200, Env: make(map[string]string), Windows: []Window{ diff --git a/main.go b/main.go index d139750..43d1b89 100644 --- a/main.go +++ b/main.go @@ -102,17 +102,20 @@ func main() { switch options.Command { case CommandStart: - if len(options.Windows) == 0 { - fmt.Println("Starting a new session...") - } else { - fmt.Println("Starting new windows...") - } config, err := GetConfig(configPath, options.Settings) if err != nil { fmt.Fprint(os.Stderr, err.Error()) os.Exit(1) } + if !config.Silent { + if len(options.Windows) == 0 { + fmt.Println("Starting a new session...") + } else { + fmt.Println("Starting new windows...") + } + } + err = smug.Start(config, options, context) if err != nil { fmt.Println("Oops, an error occurred! Rolling back...")