-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: auto-handle hiding/showing the images on tmux window switch
- Loading branch information
Showing
8 changed files
with
105 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
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 == "on\n" then has_passthrough = true end | ||
end | ||
|
||
local create_dm_getter = function(name) | ||
return function() | ||
local result = vim.fn.system("tmux display-message -p '#{" .. name .. "}'") | ||
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_window_id = create_dm_getter("window_id"), | ||
get_window_name = create_dm_getter("window_name"), | ||
get_pane_id = create_dm_getter("pane_id"), | ||
get_pane_pid = create_dm_getter("pane_pid"), | ||
get_pane_tty = create_dm_getter("pane_tty"), | ||
escape = escape, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters