diff --git a/init.lua b/init.lua index 1b837c4..17956d0 100644 --- a/init.lua +++ b/init.lua @@ -359,12 +359,14 @@ require("which-key").add ({ } }) - -- See :help terminal-events, we can use this to implement cd commands etc changing the working directory of the nvim host and other terminal app to nvim host ipc. - vim.api.nvim_create_autocmd({ 'TermRequest' }, { - desc = 'Handles OSC 7 dir change requests', - callback = function(ev) - local dir = string.gsub(vim.v.termrequest, '\x1b]7;file://[^/]*', '') - print(dir) - end - }) +-- sleep 5 && printf "\033]7;file://${PWD}/foo/bar\033\\" +vim.api.nvim_create_autocmd({ 'TermRequest' }, { + desc = 'Handles OSC 7 dir change requests', + callback = function(ev) + if string.sub(vim.v.termrequest, 1, 4) == '\x1b]7;' then + local dir = string.gsub(vim.v.termrequest, '\x1b]7;file://[^/.]*', '') + vim.cmd("cd " .. dir) + end + end +})