From a1228e0aa1757e5c15da18be4ff2920c93454eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sun, 24 Oct 2021 16:52:38 +0900 Subject: [PATCH] Set terminal title to currently focused file --- helix-term/src/ui/editor.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index 9234bb964..5dc9f8ebf 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -575,6 +575,19 @@ impl EditorView { surface.set_style(viewport.with_height(1), style); if is_focused { surface.set_string(viewport.x + 1, viewport.y, mode, style); + + // TODO: put this in a better place and possibly cache + let _ = crossterm::execute!( + std::io::stdout(), + crossterm::terminal::SetTitle(format!( + "{} - Helix", + doc.relative_path() + .as_deref() + .unwrap_or(std::path::Path::new("[scratch]")) + .to_str() + .unwrap() + )) + ); } surface.set_string(viewport.x + 5, viewport.y, progress, style);