mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-11 13:51:01 -05:00
Pass existing CLI parameters to SpawnNewInstance
Co-authored-by: Christian Duerr <contact@christianduerr.com>
This commit is contained in:
parent
5ee7ae8a27
commit
1bf40a8cc7
3 changed files with 21 additions and 4 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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(|| {
|
||||
|
|
Loading…
Reference in a new issue