diff options
Diffstat (limited to 'home/common/modules/neovim/config/lua')
-rw-r--r-- | home/common/modules/neovim/config/lua/pacman/plugins/toggleterm.lua | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/home/common/modules/neovim/config/lua/pacman/plugins/toggleterm.lua b/home/common/modules/neovim/config/lua/pacman/plugins/toggleterm.lua index e61b9b6..3a10b0c 100644 --- a/home/common/modules/neovim/config/lua/pacman/plugins/toggleterm.lua +++ b/home/common/modules/neovim/config/lua/pacman/plugins/toggleterm.lua @@ -1,3 +1,14 @@ +math.randomseed(os.time()) +local session_name = "_nvim_toggleterm_" .. vim.fn.getcwd() .. math.random() +session_name = session_name:gsub('%W', '') + +local cmd = "tmux new-session -ds " .. session_name .. + [[ \; set -t ]] .. session_name .. " destroy-unattached " .. + [[ \; set -t ]] .. + session_name .. " window-status-current-format '#{window_index}:#{pane_current_command}' " .. + [[ \; set -t ]] .. session_name .. " window-status-format '#{window_index}:#{pane_current_command}' " .. + [[ \; attach -t ]] .. session_name + return { { "akinsho/toggleterm.nvim", @@ -5,14 +16,7 @@ return { opts = { direction = "float", open_mapping = [[<c-\>]], - on_create = function(term) - local session_name = "_nvim_toggleterm_" .. vim.fn.getcwd() .. "_$(date +%s%4N)" - term:send("exec tmux new-session -A -s " .. session_name) - term:send("tmux set-option destroy-unattached") - term:send("tmux set window-status-current-format '#{window_index}:#{pane_current_command}'") - term:send("tmux set window-status-format '#{window_index}:#{pane_current_command}'") - term:clear() - end, + shell = cmd, }, } } |