diff --git a/lua/sidekick/cli/session/tmux.lua b/lua/sidekick/cli/session/tmux.lua index 942ed7d1..0d649b8f 100644 --- a/lua/sidekick/cli/session/tmux.lua +++ b/lua/sidekick/cli/session/tmux.lua @@ -79,6 +79,9 @@ function M:add_cmd(ret) vim.list_extend(ret, { "-e", ("%s=%s"):format(key, tostring(value)) }) end end + if Config.cli.mux.direnv and vim.fn.executable("direnv") == 1 then + vim.list_extend(ret, { "direnv", "exec", self.cwd }) + end vim.list_extend(ret, self.tool.cmd) end diff --git a/lua/sidekick/config.lua b/lua/sidekick/config.lua index 564617ee..9c65eb0c 100644 --- a/lua/sidekick/config.lua +++ b/lua/sidekick/config.lua @@ -94,6 +94,10 @@ local defaults = { vertical = true, -- vertical or horizontal split size = 0.5, -- size of the split (0-1 for percentage) }, + -- when true and `direnv` is on PATH, tool commands spawned in external + -- tmux panes are wrapped with `direnv exec ` so per-project + -- .envrc files are applied. + direnv = false, }, --- Actual cli tool config is loaded from the runtime path `sk/cli/{tool}.lua` and merged with the config below. --- For default configs, see https://github.com/folke/sidekick.nvim/tree/main/sk/cli