akinsho / toggleterm.nvim

A neovim lua plugin to help easily manage multiple terminal windows
GNU General Public License v3.0
4.21k stars 170 forks source link

Help Request: Issues trying to set toggle-term on Windows #531

Closed F2BEAR closed 7 months ago

F2BEAR commented 8 months ago

Hey everyone! Perhaps this is too of a nooby issue but I'm having problems trying to set toggle-term in my computer.

I'm using LazyVim on NVIM v0.9.5; runing it on a windows 10 pc with the Windows Terminal and git-bash.

For some reason when I try to open it up I got the error message /usr/bin/bash: /s: No such file or directory.

I'd tried to set my terminal to open in C:/Users/<myusername>/ but failed doing so.

Here is my config file:

-- ~\nvim\lua\plugins\toggle-term.lua
return {
  {
    "akinsho/toggleterm.nvim",
    config = true,
    cmd = "ToggleTerm",
    build = ":ToggleTerm",
    keys = { "<F4>", "<cmd>ToggleTerm<cr>", desc = "Toggle terminal" },
    opts = {
      size = 15,
      dir = "C:/Users/<myusername>/",
      open_mapping = "<F4>",
      direction = "horizontal",
      hide_numbers = true,
      insert_mappings = true,
      terminal_mappings = true,
      close_on_exit = true,
      start_in_intert = true,
    },
  },
}

I'd also tried adding it inside the keys object like <cmd>ToggleTerm dir=C:/Users/<myusername>/<cd> but that didn't work either.

Do anybody see anything that may be causing the issue?

P.D.: The rest of the config works fine so I'm definitely doing something wrong here.

dan-rigby commented 8 months ago

I'm having the exact same issue. Except I'm on Windows 11.

NilsNachname commented 7 months ago

I am experiencing the same issue on Windows 11.

NilsNachname commented 7 months ago

@F2BEAR and @dan-rigby, try this:


local bash_options = {
    shell = "bash.exe",
    shellcmdflag = "--login -i -c",
    shellredir = "",
    shellpipe = "2>&1",
    shellquote = "",
    shellxquote = "",
}

for option, value in pairs(bash_options) do
    vim.opt[option] = value
end
F2BEAR commented 7 months ago

I found what the issue was, in my case I had a typo in the config of toggleterm itself; I did start_in_intert = true instead of start_in_insert.

Then thanks to this answer I added git-bash as the default terminal.

But I think that @NilsNachname is probably the right way to config this.