mirror of
https://github.com/alacritty/alacritty
synced 2024-10-01 13:33:54 +00:00
Pass existing CLI parameters to SpawnNewInstance
Co-authored-by: Christian Duerr <contact@christianduerr.com>
This commit is contained in:
parent
5ee7ae8a27
commit
1bf40a8cc7
|
@ -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
|
- 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
|
- 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
|
- 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
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -299,10 +299,11 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
|
||||||
}
|
}
|
||||||
|
|
||||||
fn spawn_new_instance(&mut self) {
|
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)]
|
#[cfg(unix)]
|
||||||
let args = {
|
let mut args = {
|
||||||
// Use working directory of controlling process, or fallback to initial shell.
|
// Use working directory of controlling process, or fallback to initial shell.
|
||||||
let mut pid = unsafe { libc::tcgetpgrp(tty::master_fd()) };
|
let mut pid = unsafe { libc::tcgetpgrp(tty::master_fd()) };
|
||||||
if pid < 0 {
|
if pid < 0 {
|
||||||
|
@ -314,12 +315,27 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
let link_path = format!("/compat/linux/proc/{}/cwd", pid);
|
let link_path = format!("/compat/linux/proc/{}/cwd", pid);
|
||||||
|
|
||||||
|
// Add the current working directory as parameter.
|
||||||
fs::read_link(link_path)
|
fs::read_link(link_path)
|
||||||
.map(|path| vec!["--working-directory".into(), path])
|
.map(|path| vec!["--working-directory".into(), path])
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[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);
|
start_daemon(&alacritty, &args);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2823,7 +2823,7 @@ mod benches {
|
||||||
|
|
||||||
let config = MockConfig::default();
|
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);
|
mem::swap(&mut terminal.grid, &mut grid);
|
||||||
|
|
||||||
b.iter(|| {
|
b.iter(|| {
|
||||||
|
|
Loading…
Reference in a new issue