diff options
author | Nathan Lilienthal <nathan@nixpulvis.com> | 2020-11-06 23:48:48 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-07 04:48:48 +0000 |
commit | 4fc35f6038256078e7030bf95b6260cc5390bb4f (patch) | |
tree | 2c073f92f77c09cdee801a336498645aaa9043e6 /alacritty/src/event.rs | |
parent | 43d1afbeeb9cba0ce1281a9cf2223b5bd71664d2 (diff) | |
download | r-alacritty-4fc35f6038256078e7030bf95b6260cc5390bb4f.tar.gz r-alacritty-4fc35f6038256078e7030bf95b6260cc5390bb4f.tar.bz2 r-alacritty-4fc35f6038256078e7030bf95b6260cc5390bb4f.zip |
Spawn new alacritty processes in CWD on macOS
On macOS we can use 'proc_pidinfo' to determine the working
directory of the terminal foreground process.
Fixes #1979.
Diffstat (limited to 'alacritty/src/event.rs')
-rw-r--r-- | alacritty/src/event.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs index 0f9c24a5..20f087c3 100644 --- a/alacritty/src/event.rs +++ b/alacritty/src/event.rs @@ -4,7 +4,7 @@ use std::borrow::Cow; use std::cmp::{max, min}; use std::env; use std::fmt::Debug; -#[cfg(unix)] +#[cfg(not(any(target_os = "macos", windows)))] use std::fs; use std::fs::File; use std::io::Write; @@ -45,6 +45,8 @@ use crate::config::Config; use crate::daemon::start_daemon; use crate::display::{Display, DisplayUpdate}; use crate::input::{self, ActionContext as _, FONT_SIZE_STEP}; +#[cfg(target_os = "macos")] +use crate::macos; use crate::message_bar::{Message, MessageBuffer}; use crate::scheduler::{Scheduler, TimerId}; use crate::url::{Url, Urls}; @@ -309,15 +311,17 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon pid = tty::child_pid(); } - #[cfg(not(target_os = "freebsd"))] + #[cfg(not(any(target_os = "macos", target_os = "freebsd")))] let link_path = format!("/proc/{}/cwd", pid); #[cfg(target_os = "freebsd")] let link_path = format!("/compat/linux/proc/{}/cwd", pid); + #[cfg(not(target_os = "macos"))] + let cwd = fs::read_link(link_path); + #[cfg(target_os = "macos")] + let cwd = macos::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() + cwd.map(|path| vec!["--working-directory".into(), path]).unwrap_or_default() }; #[cfg(not(unix))] |