Skip to content

Instantly share code, notes, and snippets.

@robertgzr
Last active December 18, 2020 15:47
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertgzr/34e1a90b885037e2ccef870740f4763d to your computer and use it in GitHub Desktop.
Save robertgzr/34e1a90b885037e2ccef870740f4763d to your computer and use it in GitHub Desktop.
new window patch for https://github.com/jwilm/alacritty
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);
@myklv
Copy link

myklv commented Jul 30, 2017

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:

- { key: N,        mods: Command, action: OpenNewWindow                }

Is there something I might be doing wrong? I applied the patch with git apply before compiling.

@myklv
Copy link

myklv commented Jul 30, 2017

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)

@myklv
Copy link

myklv commented Jul 30, 2017

Nevermind, I see the issue was that I did not have the binary installed at /usr/local/bin/alacritty

@kergoth
Copy link

kergoth commented Jun 4, 2018

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"] } }

@suhlig
Copy link

suhlig commented Aug 5, 2019

Thank you, @kergoth. Very useful.

@timemachine3030
Copy link

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