Skip to content

Commit f1dbe1c

Browse files
committed
fix: live reloading for ghostty and helix
1 parent fb304e9 commit f1dbe1c

1 file changed

Lines changed: 18 additions & 6 deletions

File tree

src/target.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::fs;
22
use std::path::{Path, PathBuf};
3+
use std::process::Command;
34

45
use jsonc_parser::ParseOptions;
56
use jsonc_parser::cst::{CstInputValue, CstRootNode};
@@ -84,12 +85,23 @@ impl Target {
8485
let updated = self.apply_theme(&original, theme)?;
8586
let changed = write_target(&path, *self, &original, &updated, dry_run)?;
8687

87-
// SIGUSR2 to reload ghostty config
88-
// refer to https://github.com/ghostty-org/ghostty/issues/7747
89-
if changed && !dry_run && matches!(self, Self::Ghostty) {
90-
let _ = std::process::Command::new("killall")
91-
.args(["-USR2", "ghostty"])
92-
.status();
88+
if changed && !dry_run {
89+
match self {
90+
// SIGUSR2 to reload ghostty config.
91+
// Refer to https://github.com/ghostty-org/ghostty/issues/7747.
92+
Self::Ghostty => {
93+
let _ = Command::new("pkill")
94+
.args(["-USR2", "-x", "ghostty"])
95+
.status();
96+
}
97+
// SIGUSR1 to reload helix config
98+
// Refer to https://github.com/helix-editor/helix/issues/2158#issuecomment-1910775800
99+
Self::Helix => {
100+
let _ = Command::new("pkill").args(["-USR1", "-x", "hx"]).status();
101+
}
102+
// Zed hot reloads
103+
Self::Zed => {}
104+
}
93105
}
94106

95107
Ok(true)

0 commit comments

Comments
 (0)