-
I'm trying to use snacks.terminal to toggle a terminal, but when a terminal is already opened and I'm not in the buffer for the terminal I want to select the already existing terminal instead of toggling it. Right now toggle will simply hide the terminal. I see there's Snacks.terminal.list() and I would always select the first one, but I don't know what to do with this terminal once I have it to select it. |
Beta Was this translation helpful? Give feedback.
Answered by
IceSentry
Aug 15, 2025
Replies: 1 comment 2 replies
-
I figured it out after looking at it a bit more local toggle_terminal = function()
local list = Snacks.terminal.list()
if #list > 0 then
if vim.bo.buftype ~= "terminal" then
local terminal = list[1]
terminal:show()
terminal:focus()
end
else
Snacks.terminal()
end
end |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
IceSentry
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I figured it out after looking at it a bit more