From d2adbb888c63b6d83282c0a81027d94ae6c19223 Mon Sep 17 00:00:00 2001 From: Felix Cusson Date: Sat, 18 Mar 2023 16:46:22 -0400 Subject: [PATCH 1/2] added option to quote the command passed to the terminal --- lua/toggleterm/terminal.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/toggleterm/terminal.lua b/lua/toggleterm/terminal.lua index 59702dfd..a4271307 100644 --- a/lua/toggleterm/terminal.lua +++ b/lua/toggleterm/terminal.lua @@ -375,13 +375,16 @@ function Terminal:__spawn() local cmd = self.cmd or config.get("shell") 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, { From e165f3f549b587dba8f33c63f05fef18d6aa84d6 Mon Sep 17 00:00:00 2001 From: Felix Cusson Date: Sat, 18 Mar 2023 17:09:15 -0400 Subject: [PATCH 2/2] documented and added option to default config --- README.md | 1 + doc/toggleterm.txt | 1 + lua/toggleterm/config.lua | 1 + 3 files changed, 3 insertions(+) diff --git a/README.md b/README.md index a3d37d0c..b58ec880 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,7 @@ require("toggleterm").setup{ direction = 'vertical' | 'horizontal' | 'tab' | 'float', close_on_exit = true, -- close the terminal window when the process exits shell = vim.o.shell, -- change the default 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 0e87f7fc..5a5e1639 100644 --- a/doc/toggleterm.txt +++ b/doc/toggleterm.txt @@ -185,6 +185,7 @@ show what options are available. It is not written to be used as is. direction = 'vertical' | 'horizontal' | 'tab' | 'float', close_on_exit = true, -- close the terminal window when the process exits shell = vim.o.shell, -- change the default 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 44523fcd..73c06393 100644 --- a/lua/toggleterm/config.lua +++ b/lua/toggleterm/config.lua @@ -50,6 +50,7 @@ local config = { direction = "horizontal", shading_factor = constants.shading_amount, shell = vim.o.shell, + quote_command = false, autochdir = false, auto_scroll = true, winbar = {