Implement working dir integration with neovim terminal bash cd command
This commit is contained in:
parent
294d39665f
commit
7b2adb5411
12
init.lua
12
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.
|
-- 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' }, {
|
-- sleep 5 && printf "\033]7;file://${PWD}/foo/bar\033\\"
|
||||||
|
vim.api.nvim_create_autocmd({ 'TermRequest' }, {
|
||||||
desc = 'Handles OSC 7 dir change requests',
|
desc = 'Handles OSC 7 dir change requests',
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
local dir = string.gsub(vim.v.termrequest, '\x1b]7;file://[^/]*', '')
|
if string.sub(vim.v.termrequest, 1, 4) == '\x1b]7;' then
|
||||||
print(dir)
|
local dir = string.gsub(vim.v.termrequest, '\x1b]7;file://[^/.]*', '')
|
||||||
|
vim.cmd("cd " .. dir)
|
||||||
end
|
end
|
||||||
})
|
end
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue