From 30ae7ba8d16c39767b48396ebaeba98a231c3cf2 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Sat, 6 Sep 2025 12:04:17 +0530 Subject: chore(home/neovim/toggleterm): clean up --- .../neovim/config/lua/pacman/plugins/toggleterm.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'home') 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 = [[]], - 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, }, } } -- cgit v1.2.3