diff --git a/flake.lock b/flake.lock index 656ebe7..b2d1a6c 100644 --- a/flake.lock +++ b/flake.lock @@ -36,11 +36,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1740162160, - "narHash": "sha256-SSYxFhqCOb3aiPb6MmN68yEzBIltfom8IgRz7phHscM=", + "lastModified": 1741862977, + "narHash": "sha256-prZ0M8vE/ghRGGZcflvxCu40ObKaB+ikn74/xQoNrGQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "11415c7ae8539d6292f2928317ee7a8410b28bb9", + "rev": "cdd2ef009676ac92b715ff26630164bb88fec4e0", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 0f10af9..1df5f6b 100644 --- a/flake.nix +++ b/flake.nix @@ -26,14 +26,14 @@ system: let pkgs = nixpkgs.legacyPackages.${system}; - version = "0.3.0"; + version = "0.4.0"; in { packages.workon = pkgs.buildGoModule { pname = "workon"; version = version; src = ./.; - vendorHash = "sha256-HLjR2041wlhOzfKG6PQe5/DVfAEAX6O7/jd2E/lJ43E="; + vendorHash = "sha256-p3bwgNUbUsgJfANIOxG/+GXeh2/OddxYs0EK3JfnD4s="; ldflags = [ "-s -w -X github.com/walkah/workon/cmd.version=${version}" diff --git a/go.mod b/go.mod index f022360..3501e26 100644 --- a/go.mod +++ b/go.mod @@ -26,9 +26,9 @@ require ( github.com/spf13/pflag v1.0.6 // indirect github.com/subosito/gotenv v1.6.0 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa // indirect - golang.org/x/sys v0.30.0 // indirect - golang.org/x/text v0.22.0 // indirect + golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/text v0.23.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 8d567f5..ab8d6f5 100644 --- a/go.sum +++ b/go.sum @@ -66,14 +66,20 @@ golang.org/x/exp v0.0.0-20241210194714-1829a127f884 h1:Y/Mj/94zIQQGHVSv1tTtQBDaQ golang.org/x/exp v0.0.0-20241210194714-1829a127f884/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4= golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk= +golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw= +golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/tmux/project.go b/tmux/project.go index a5d4541..045d4ad 100644 --- a/tmux/project.go +++ b/tmux/project.go @@ -15,11 +15,12 @@ import ( ) type Project struct { - Name string `yaml:"name"` - Root string `yaml:"root"` - OnProjectStart []string `yaml:"on_project_start,omitempty"` - OnProjectStop []string `yaml:"on_project_stop,omitempty"` - Windows []Window `yaml:"windows"` + Name string `yaml:"name"` + Root string `yaml:"root"` + Environment map[string]string `yaml:"environment"` + OnProjectStart []string `yaml:"on_project_start,omitempty"` + OnProjectStop []string `yaml:"on_project_stop,omitempty"` + Windows []Window `yaml:"windows"` } func StartProject(name string) { @@ -36,6 +37,8 @@ func StartProject(name string) { p.RunCommands(p.OnProjectStart) tmux.Run("new-session", "-d", "-s", name, "-n", p.Windows[0].Name, "-c", p.Windows[0].Root) + + p.SetEnvironment(tmux, name, p.Environment) for index, window := range p.Windows { if index > 0 { window.Create(tmux) @@ -217,6 +220,12 @@ func (p *Project) RunCommands(commands []string) { } } +func (p *Project) SetEnvironment(tmux *Tmux, target string, environment map[string]string) { + for key, value := range environment { + tmux.Run("setenv", "-t", target, key, value) + } +} + func getConfigDir() string { home, _ := homedir.Dir() return path.Join(home, ".workon")