From 72b550592712f10fddf572893fc2525f33adec06 Mon Sep 17 00:00:00 2001 From: Filip Czaplicki Date: Thu, 4 Dec 2025 00:13:40 +0100 Subject: [PATCH] feat: add colors to --help/-h (#3000) ## Checks - [x] I am happy for maintainers to push small adjustments to this PR, to speed up the review cycle - [x] I have checked that there are no existing pull requests for the same thing User can disable colors via `NO_COLOR=1` environment variable if needed Output of `atuin -h`: | before | after | `NO_COLOR=1` | | - | - | - | | atuin-before | atuin-colors | atuin-no-color | --- crates/atuin/src/main.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/atuin/src/main.rs b/crates/atuin/src/main.rs index 8b6947e3..1a45988a 100644 --- a/crates/atuin/src/main.rs +++ b/crates/atuin/src/main.rs @@ -2,6 +2,8 @@ #![allow(clippy::use_self, clippy::missing_const_for_fn)] // not 100% reliable use clap::Parser; +use clap::builder::Styles; +use clap::builder::styling::{AnsiColor, Effects}; use eyre::Result; use command::AtuinCmd; @@ -26,6 +28,12 @@ static HELP_TEMPLATE: &str = "\ {all-args}{after-help}"; +const STYLES: Styles = Styles::styled() + .header(AnsiColor::Yellow.on_default().effects(Effects::BOLD)) + .usage(AnsiColor::Green.on_default().effects(Effects::BOLD)) + .literal(AnsiColor::Green.on_default().effects(Effects::BOLD)) + .placeholder(AnsiColor::Green.on_default()); + /// Magical shell history #[derive(Parser)] #[command( @@ -33,6 +41,7 @@ static HELP_TEMPLATE: &str = "\ version = VERSION, long_version = LONG_VERSION, help_template(HELP_TEMPLATE), + styles = STYLES, )] struct Atuin { #[command(subcommand)]