summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRohan Poojary <rohanrp23@gmail.com>2020-09-06 21:08:49 +0530
committerGitHub <noreply@github.com>2020-09-06 15:38:49 +0000
commit1bf40a8cc77d9082dfb76e028e0f66af88d79958 (patch)
treece749ba8df89e8645b6184ee16827c3a0bd4b797
parent5ee7ae8a274fcc58754aa5a91a14b1dedbb87583 (diff)
Pass existing CLI parameters to SpawnNewInstance
Co-authored-by: Christian Duerr <contact@christianduerr.com>
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/event.rs22
-rw-r--r--alacritty_terminal/src/term/mod.rs2
3 files changed, 21 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4e84ec91..b8e4b224 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Fallback to normal underline for unsupported underline types in `CSI 4 : ? m` escapes
- The user's background color is now used as the foreground for the render timer
- Use yellow/red from the config for error and warning messages instead of fixed colors
+- Existing CLI parameters are now passed to instances spawned using `SpawnNewInstance`
### Fixed
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index c3e1b6c8..e81dc0f9 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -299,10 +299,11 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
}
fn spawn_new_instance(&mut self) {
- let alacritty = env::args().next().unwrap();
+ let mut env_args = env::args();
+ let alacritty = env_args.next().unwrap();
#[cfg(unix)]
- let args = {
+ let mut args = {
// Use working directory of controlling process, or fallback to initial shell.
let mut pid = unsafe { libc::tcgetpgrp(tty::master_fd()) };
if pid < 0 {
@@ -314,12 +315,27 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
#[cfg(target_os = "freebsd")]
let link_path = format!("/compat/linux/proc/{}/cwd", pid);
+ // Add the current working directory as parameter.
fs::read_link(link_path)
.map(|path| vec!["--working-directory".into(), path])
.unwrap_or_default()
};
+
#[cfg(not(unix))]
- let args: Vec<String> = Vec::new();
+ let mut args: Vec<PathBuf> = Vec::new();
+
+ let working_directory_set = !args.is_empty();
+
+ // Reuse the arguments passed to Alacritty for the new instance.
+ while let Some(arg) = env_args.next() {
+ // Drop working directory from existing parameters.
+ if working_directory_set && arg == "--working-directory" {
+ let _ = env_args.next();
+ continue;
+ }
+
+ args.push(arg.into());
+ }
start_daemon(&alacritty, &args);
}
diff --git a/alacritty_terminal/src/term/mod.rs b/alacritty_terminal/src/term/mod.rs
index 15499e07..d61cf7e3 100644
--- a/alacritty_terminal/src/term/mod.rs
+++ b/alacritty_terminal/src/term/mod.rs
@@ -2823,7 +2823,7 @@ mod benches {
let config = MockConfig::default();
- let mut terminal = Term::new(&config, &size, Mock);
+ let mut terminal = Term::new(&config, size, Mock);
mem::swap(&mut terminal.grid, &mut grid);
b.iter(|| {