Last active
December 18, 2020 15:47
-
-
Save robertgzr/34e1a90b885037e2ccef870740f4763d to your computer and use it in GitHub Desktop.
new window patch for https://github.com/jwilm/alacritty
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
diff --git a/src/config.rs b/src/config.rs | |
index 5142b9b..80fe5a2 100644 | |
--- a/src/config.rs | |
+++ b/src/config.rs | |
@@ -369,6 +369,7 @@ impl de::Deserialize for ActionWrapper { | |
"Paste" => Action::Paste, | |
"Copy" => Action::Copy, | |
"PasteSelection" => Action::PasteSelection, | |
+ "OpenNewWindow" => Action::OpenNewWindow, | |
"Quit" => Action::Quit, | |
_ => return Err(E::invalid_value(Unexpected::Str(value), &self)), | |
})) | |
diff --git a/src/input.rs b/src/input.rs | |
index de8bca4..9fdaa2f 100644 | |
--- a/src/input.rs | |
+++ b/src/input.rs | |
@@ -148,6 +148,9 @@ pub enum Action { | |
/// Run given command | |
Command(String, Vec<String>), | |
+ /// Opens a new window | |
+ OpenNewWindow, | |
+ | |
/// Quits Alacritty. | |
Quit, | |
} | |
@@ -189,6 +192,14 @@ impl Action { | |
}, | |
} | |
}, | |
+ Action::OpenNewWindow => { | |
+ ::std::process::Command::new("/usr/local/bin/alacritty") | |
+ .spawn() | |
+ .map(|child| { println!("subproces pid: {}", child.id()) }) | |
+ .unwrap_or_else(|err| { | |
+ warn!("Error spawning subprocess. {}", Red(err)); | |
+ }); | |
+ } | |
Action::Quit => { | |
// FIXME should do a more graceful shutdown | |
::std::process::exit(0); |
Actually, running it on the command line instead of through Alacritty.app, I'm getting this:
Error spawning subprocess. No such file or directory (os error 2)
Nevermind, I see the issue was that I did not have the binary installed at /usr/local/bin/alacritty
This is workable without a patch using the 'command' mechanism (though this particular example is mac-specific):
- { key: N, mods: Command, command: { program: "open", args: ["-nb", "io.alacritty"] } }
Thank you, @kergoth. Very useful.
For Linux, if alacritty is in your path, Alt+n
- { key: N, mods: Alt, command: { program: "alacritty", args: [] } }
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Doesn't seem to work for me. (Just doesn't do anything.) macOS 10.12.5, alacritty at 9b13e344f0be068982845694442489e4932ccd5d, Rust at latest stable. I've added this to my
~/.config/alacritty/alacritty.yml
:Is there something I might be doing wrong? I applied the patch with
git apply
before compiling.