worktree_io/opener/
entries.rs1pub enum DetectMethod {
3 Path(&'static str),
5 #[cfg(target_os = "macos")]
7 MacosApp(&'static str),
8 Always,
10}
11
12pub struct EditorEntry {
14 pub aliases: &'static [&'static str],
16 pub display: &'static str,
18 pub command: &'static str,
20 pub detect: DetectMethod,
22}
23
24const BASE: &[(&[&str], &str, &str, &str)] = &[
26 (&["cursor"], "Cursor", "cursor .", "cursor"),
27 (&["vscode", "code"], "VS Code", "code .", "code"),
28 (&["zed"], "Zed", "zed .", "zed"),
29 (&["subl"], "Sublime Text", "subl .", "subl"),
30 (&["nvim"], "Neovim", "nvim .", "nvim"),
31 (&["vim"], "Vim", "vim .", "vim"),
32 (&["tmux"], "tmux", "tmux", "tmux"),
33 (
34 &["alacritty"],
35 "Alacritty",
36 "alacritty --working-directory .",
37 "alacritty",
38 ),
39 (&["kitty"], "Kitty", "kitty --directory .", "kitty"),
40 (&["wezterm"], "WezTerm", "wezterm start --cwd .", "wezterm"),
41];
42
43#[must_use]
45#[allow(unused_mut)]
46pub fn all_entries() -> Vec<EditorEntry> {
47 let mut v: Vec<EditorEntry> = BASE
48 .iter()
49 .map(|&(aliases, display, command, binary)| EditorEntry {
50 aliases,
51 display,
52 command,
53 detect: DetectMethod::Path(binary),
54 })
55 .collect();
56 #[cfg(target_os = "macos")]
57 {
58 use DetectMethod::{Always, MacosApp};
59 v.push(EditorEntry {
60 aliases: &["terminal"],
61 display: "Terminal",
62 command: "open -a Terminal .",
63 detect: Always,
64 });
65 v.push(EditorEntry {
66 aliases: &["iterm", "iterm2"],
67 display: "iTerm2",
68 command: "open -a iTerm .",
69 detect: MacosApp("iTerm"),
70 });
71 v.push(EditorEntry {
72 aliases: &["warp"],
73 display: "Warp",
74 command: "open -a Warp .",
75 detect: MacosApp("Warp"),
76 });
77 v.push(EditorEntry {
78 aliases: &["ghostty"],
79 display: "Ghostty",
80 command: "open -a Ghostty .",
81 detect: MacosApp("Ghostty"),
82 });
83 }
84 #[cfg(target_os = "windows")]
85 v.push(EditorEntry {
86 aliases: &["wt", "windowsterminal", "terminal"],
87 display: "Windows Terminal",
88 command: "wt -d .",
89 detect: DetectMethod::Path("wt"),
90 });
91 v
92}