diff --git a/README.md b/README.md index 632d057c..fe25164d 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,7 @@ require("toggleterm").setup{ close_on_exit = true, -- close the terminal window when the process exits -- Change the default shell. Can be a string or a function returning a string shell = vim.o.shell, + quote_command = false, -- put quotes arround the command sent to the terminal, required for Windows using git bash auto_scroll = true, -- automatically scroll to the bottom on terminal output -- This field is only relevant if direction is set to 'float' float_opts = { diff --git a/doc/toggleterm.txt b/doc/toggleterm.txt index 7e08147f..49374c9f 100644 --- a/doc/toggleterm.txt +++ b/doc/toggleterm.txt @@ -183,6 +183,7 @@ what options are available. It is not written to be used as is. close_on_exit = true, -- close the terminal window when the process exits -- Change the default shell. Can be a string or a function returning a string shell = vim.o.shell, + quote_command = false -- put quotes around the command being sent to the terminal. Required for Windows using git bash auto_scroll = true, -- automatically scroll to the bottom on terminal output -- This field is only relevant if direction is set to 'float' float_opts = { diff --git a/lua/toggleterm/config.lua b/lua/toggleterm/config.lua index feebe5f5..4d75a4e4 100644 --- a/lua/toggleterm/config.lua +++ b/lua/toggleterm/config.lua @@ -51,6 +51,7 @@ local config = { direction = "horizontal", shading_factor = constants.shading_amount, shell = vim.o.shell, + quote_command = false, autochdir = false, auto_scroll = true, winbar = { diff --git a/lua/toggleterm/terminal.lua b/lua/toggleterm/terminal.lua index 904eb340..971469c3 100644 --- a/lua/toggleterm/terminal.lua +++ b/lua/toggleterm/terminal.lua @@ -392,13 +392,16 @@ function Terminal:__spawn() if type(cmd) == "function" then cmd = cmd() end local command_sep = get_command_sep() local comment_sep = get_comment_sep() + local quote = config.get("quote_command") and "\"" or "" cmd = table.concat({ + quote, cmd, command_sep, comment_sep, constants.FILETYPE, comment_sep, self.id, + quote, }) local dir = _get_dir(self.dir) self.job_id = fn.termopen(cmd, {