FTerm.nvim icon indicating copy to clipboard operation
FTerm.nvim copied to clipboard

Automatic CWD on every enter.

Open marendowski opened this issue 1 year ago • 2 comments

Hi, I tried setting up this terminal so it will automatically enter cwd on the current buffer when is opened, but cannot achieve it. Here' s what I tried:

-- this opens normally but doesn't change cwd
vim.api.nvim_create_user_command('FTermToggle', require('FTerm').toggle, { bang = true })

vim.keymap.set('n', '<C-\\>', '<CMD>FTermToggle<CR>')
vim.keymap.set('t', '<C-\\>', '<CMD>FTermToggle<CR>')
-- returns: `No such group or event: FTermToggle * :lcd%:p:h`
vim.cmd("autocmd! FTermToggle * :lcd%:p:h")
-- returns `Invalid 'event': 'FTermToggle'`
vim.api.nvim_create_autocmd("FTermToggle", {
     pattern = "*",
     callback = function()
     vim.cmd('cd ' .. vim.loop.cwd())
end,
})

And tried setting cmd option to:

cmd = os.getenv('SHELL') .. ' -c "cd ' .. vim.cmd(':lcd%:p:h')  .. '"'

But nothing works like it should. Also I have enabled autochdir but it doesn't do anything.

marendowski avatar Nov 30 '23 10:11 marendowski