Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions codex-rs/tui/src/tui.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::io::Result;
use std::io::Stdout;
use std::io::stdout;
use std::env;

use codex_core::config::Config;
use crossterm::cursor::MoveTo;
Expand All @@ -11,6 +12,7 @@ use crossterm::event::PopKeyboardEnhancementFlags;
use crossterm::event::PushKeyboardEnhancementFlags;
use crossterm::terminal::Clear;
use crossterm::terminal::ClearType;
use crossterm::terminal::SetTitle;
use ratatui::backend::CrosstermBackend;
use ratatui::crossterm::execute;
use ratatui::crossterm::terminal::disable_raw_mode;
Expand Down Expand Up @@ -42,8 +44,19 @@ pub fn init(_config: &Config) -> Result<Tui> {
);
set_panic_hook();

// Clear screen and move cursor to top-left before drawing UI
execute!(stdout(), Clear(ClearType::All), MoveTo(0, 0))?;
// Set terminal title and clear screen and move cursor to top-left before drawing UI
let current_dir = env::current_dir()
.ok()
.and_then(|path| path.file_name().map(|name| name.to_string_lossy().into_owned()))
.unwrap_or_else(|| "Unknown".to_string());
let title = format!("Codex CLI | {}", current_dir);

execute!(
stdout(),
SetTitle(&title),
Clear(ClearType::All),
MoveTo(0, 0)
)?;

let backend = CrosstermBackend::new(stdout());
let tui = Terminal::with_options(backend)?;
Expand Down