Add process info to terminal so that we can show the active process in the terminal tab title

Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
K Simmons 2022-09-01 17:46:11 -07:00
parent 7cbabc386f
commit 7497edaec2
4 changed files with 77 additions and 26 deletions

View file

@ -238,9 +238,23 @@ impl Item for TerminalContainer {
cx: &gpui::AppContext,
) -> ElementBox {
let title = match &self.content {
TerminalContainerContent::Connected(connected) => {
connected.read(cx).handle().read(cx).title.to_string()
}
TerminalContainerContent::Connected(connected) => connected
.read(cx)
.handle()
.read(cx)
.foreground_process_info
.as_ref()
.map(|fpi| {
format!(
"{} - {}",
fpi.cwd
.file_name()
.map(|name| name.to_string_lossy().to_string())
.unwrap_or_default(),
fpi.name,
)
})
.unwrap_or_else(|| "Terminal".to_string()),
TerminalContainerContent::Error(_) => "Terminal".to_string(),
};