Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display which theme is the default one in basic output #2937

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
refactor: factorize constants by inverting loop and condition order
  • Loading branch information
sblondon committed Apr 17, 2024
commit 778e8731624b85d2f5f2ea6327ef788e34843c06
28 changes: 12 additions & 16 deletions src/bin/bat/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
let mut stdout = stdout.lock();

let default_theme = HighlightingAssets::default_theme();
if config.colored_output {
for theme in assets.themes() {
let default_theme_info = if default_theme == theme {
" (default)"
} else {
""
};
for theme in assets.themes() {
let default_theme_info = if default_theme == theme {
" (default)"
} else {
""
};
if config.colored_output {
writeln!(
stdout,
"Theme: {}{}\n",
Expand All @@ -219,7 +219,12 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
.run(vec![theme_preview_file()], None)
.ok();
writeln!(stdout)?;
} else {
writeln!(stdout, "{theme}{default_theme_info}")?;
}
}

if config.colored_output {
writeln!(
stdout,
"Further themes can be installed to '{}', \
Expand All @@ -228,15 +233,6 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result<
https://github.com/sharkdp/bat#adding-new-themes",
config_dir.join("themes").to_string_lossy()
)?;
} else {
for theme in assets.themes() {
let default_theme_info = if default_theme == theme {
" (default)"
} else {
""
};
writeln!(stdout, "{theme}{default_theme_info}")?;
}
}

Ok(())
Expand Down