Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

### Added
* `--no-terminal-title/-n` CLI argument to disable automatic terminal title

## [0.28.0] - 2025-12-14

**discard changes on checkout**
Expand Down
13 changes: 13 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const GIT_DIR_FLAG_ID: &str = "directory";
const WATCHER_FLAG_ID: &str = "watcher";
const KEY_BINDINGS_FLAG_ID: &str = "key_bindings";
const KEY_SYMBOLS_FLAG_ID: &str = "key_symbols";
const NO_TERMINAL_TITLE_FLAG_ID: &str = "no-terminal-title";
const DEFAULT_THEME: &str = "theme.ron";
const DEFAULT_GIT_DIR: &str = ".";

Expand All @@ -33,6 +34,7 @@ pub struct CliArgs {
pub notify_watcher: bool,
pub key_bindings_path: Option<PathBuf>,
pub key_symbols_path: Option<PathBuf>,
pub no_terminal_title: bool,
}

pub fn process_cmdline() -> Result<CliArgs> {
Expand Down Expand Up @@ -92,13 +94,17 @@ pub fn process_cmdline() -> Result<CliArgs> {
.get_one::<String>(KEY_SYMBOLS_FLAG_ID)
.map(PathBuf::from);

let no_terminal_title: bool =
*arg_matches.get_one(NO_TERMINAL_TITLE_FLAG_ID).unwrap_or(&false);

Ok(CliArgs {
theme,
select_file,
repo_path,
notify_watcher,
key_bindings_path,
key_symbols_path,
no_terminal_title,
})
}

Expand Down Expand Up @@ -190,6 +196,13 @@ fn app() -> ClapApp {
.env("GIT_WORK_TREE")
.num_args(1),
)
.arg(
Arg::new(NO_TERMINAL_TITLE_FLAG_ID)
.help("Disable setting the terminal title")
.short('n')
.long("no-terminal-title")
.action(clap::ArgAction::SetTrue),
)
}

fn setup_logging(path_override: Option<PathBuf>) -> Result<()> {
Expand Down
16 changes: 11 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fn main() -> Result<()> {
set_panic_handler()?;

let mut terminal =
start_terminal(io::stdout(), &cliargs.repo_path)?;
start_terminal(io::stdout(), &cliargs.repo_path, cliargs.no_terminal_title)?;
let input = Input::new();

let updater = if cliargs.notify_watcher {
Expand Down Expand Up @@ -217,6 +217,7 @@ fn main() -> Result<()> {
notify_watcher: args.notify_watcher,
key_bindings_path: args.key_bindings_path,
key_symbols_path: args.key_symbols_path,
no_terminal_title: args.no_terminal_title,
}
}
_ => break,
Expand Down Expand Up @@ -417,6 +418,7 @@ fn select_event(
fn start_terminal(
buf: Stdout,
repo_path: &RepoPath,
no_terminal_title: bool,
) -> Result<Terminal> {
let mut path = repo_path.gitpath().canonicalize()?;
let home = dirs::home_dir().ok_or_else(|| {
Expand All @@ -430,10 +432,14 @@ fn start_terminal(
}

let mut backend = CrosstermBackend::new(buf);
backend.execute(crossterm::terminal::SetTitle(format!(
"gitui ({})",
path.display()
)))?;

// Conditionally set terminal title
if !no_terminal_title {
backend.execute(crossterm::terminal::SetTitle(format!(
"gitui ({})",
path.display()
)))?;
}

let mut terminal = Terminal::new(backend)?;
terminal.hide_cursor()?;
Expand Down