-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pr/199 #209
Conversation
fix(kitty): image shown when switching to different tmux session #198
#199 still does not work for me. Doing some quick print debugging on the code it looks like EDIT: Ran a quick experiment with sleep 2 && tmux display-message -p '#{session_name}' And quickly step into another session before the command triggers. It will never pick up any other session name than the name of the session from where the cmd was run. (Note that this behavior is different from when running display-message from outside of tmux.) EDIT2: Changing |
I believe the correct way to get the pane TTY for deleting the image should be: tmux list-panes -t $(tmux display-message -p '#{client_session}') -F '#{pane_tty}' -f '#{pane_active}' EDIT: This local is_tmux = vim.env.TMUX ~= nil
local has_passthrough = false
if is_tmux then
local ok, result = pcall(vim.fn.system, "tmux show -Apv allow-passthrough")
if ok and result:sub(-3) == "on\n" then has_passthrough = true end
end
local create_dm_getter = function(name)
return function()
if not is_tmux then return nil end
local result = vim.fn.system("tmux display-message -p '#{" .. name .. "}'")
return vim.fn.trim(result)
end
end
local create_dm_window_getter = function(name)
return function()
if not is_tmux then return nil end
local result = vim.fn.system(
"tmux list-windows -t $(tmux display-message -p '#{client_session}') -F '#{" .. name .. "}' -f '#{window_active}'"
)
return vim.fn.trim(result)
end
end
local create_dm_pane_getter = function(name)
return function()
if not is_tmux then return nil end
local result = vim.fn.system(
"tmux list-panes -t $(tmux display-message -p '#{client_session}') -F '#{" .. name .. "}' -f '#{pane_active}'"
)
return vim.fn.trim(result)
end
end
local escape = function(sequence)
return "\x1bPtmux;" .. sequence:gsub("\x1b", "\x1b\x1b") .. "\x1b\\"
end
return {
is_tmux = is_tmux,
has_passthrough = has_passthrough,
get_pid = create_dm_getter("pid"),
get_socket_path = create_dm_getter("socket_path"),
get_current_session = create_dm_getter("client_session"),
get_window_id = create_dm_window_getter("window_id"),
get_window_name = create_dm_window_getter("window_name"),
get_pane_id = create_dm_pane_getter("pane_id"),
get_pane_pid = create_dm_pane_getter("pane_pid"),
get_pane_tty = create_dm_pane_getter("pane_tty"),
get_cursor_x = create_dm_getter("cursor_x"),
get_cursor_y = create_dm_getter("cursor_y"),
escape = escape,
} |
See #221 |
…us-getters Add TMUX session agnostic status getters
Thank you @maxbol 🙏 |
#199