-
-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switching to selected worktree directory #137
Comments
Would love this feature! https://github.com/jesseduffield/lazygit?tab=readme-ov-file#changing-directory-on-exit |
I created this temporary patch diff --git a/lua/lazygit.lua b/lua/lazygit.lua
index 770e042..3a1760c 100644
--- a/lua/lazygit.lua
+++ b/lua/lazygit.lua
@@ -37,2 +37,19 @@ local function on_exit(job_id, code, event)
end
+
+ local dir_file = os.getenv("LAZYGIT_NEW_DIR_FILE")
+
+ if dir_file then
+ local file = io.open(dir_file, "r")
+
+ if file then
+ local content = file:read("*all")
+ file:close()
+
+ vim.fn.chdir(content)
+ else
+ print("Failed to open file: " .. file)
+ end
+
+ vim.env.LAZYGIT_NEW_DIR_FILE = nil
+ end
end
@@ -41,2 +58,4 @@ end
local function exec_lazygit_command(cmd)
+ vim.env.LAZYGIT_NEW_DIR_FILE = vim.fn.expand("~/.lazygit/newdir")
+
if LAZYGIT_LOADED == false then |
@kryshac Is it possible to put this on a config file ( |
@vuthanhtung2412 is not possible because lazygit.nvim has no hook for this |
@vuthanhtung2412 file that you need to applay this path it is in |
Is your feature request related to a problem? Please describe.
I recently started working with worktrees but when opening LazyVim inside of nvim and go to the worktree section, there is no way to change the current nvim work directory to the one selected. You can press o to open the editor, but then you have a vim instance inside of the lazygit window.
Describe the solution you'd like
When switching to a worktree, it would be nice if the nvim instance would switch to the worktree folder. I do not know in how far this would be possible though and it's not a big issue, it could just save time being able to do it directly inside of lazygit.
The text was updated successfully, but these errors were encountered: