pub(super) struct TerminalGoto {
pub(super) env: &'static [&'static str],
pub(super) command: &'static str,
}
#[cfg(target_os = "macos")]
pub(super) const GHOSTTY_GOTO: &str = "open -na Ghostty --args -e tmux attach -t {session}";
#[cfg(not(target_os = "macos"))]
pub(super) const GHOSTTY_GOTO: &str = "ghostty -e tmux attach -t {session}";
pub(super) const TERMINAL_GOTOS: &[TerminalGoto] = &[
TerminalGoto {
env: &["WEZTERM_PANE"],
command: "wezterm cli spawn -- tmux attach -t {session}",
},
TerminalGoto {
env: &["KITTY_WINDOW_ID"],
command: "kitten @ launch --type=tab tmux attach -t {session}",
},
TerminalGoto {
env: &["GHOSTTY_RESOURCES_DIR"],
command: GHOSTTY_GOTO,
},
TerminalGoto {
env: &["KONSOLE_VERSION"],
command: "konsole --new-tab -e tmux attach -t {session}",
},
TerminalGoto {
env: &["ALACRITTY_SOCKET"],
command: "alacritty msg create-window -e tmux attach -t {session}",
},
TerminalGoto {
env: &["GNOME_TERMINAL_SCREEN"],
command: "gnome-terminal --tab -- tmux attach -t {session}",
},
];
pub(super) fn goto_command_for_env(present: impl Fn(&str) -> bool) -> String {
TERMINAL_GOTOS
.iter()
.find(|t| t.env.iter().any(|v| present(v)))
.map(|t| t.command.to_string())
.unwrap_or_default()
}
pub(super) fn default_goto_command() -> String {
goto_command_for_env(|v| std::env::var_os(v).is_some())
}