Skip to content

Instantly share code, notes, and snippets.

@gnachman
Created January 20, 2026 02:56
Show Gist options
  • Select an option

  • Save gnachman/1aee2d5f440bc5b82e1db405ef67195f to your computer and use it in GitHub Desktop.

Select an option

Save gnachman/1aee2d5f440bc5b82e1db405ef67195f to your computer and use it in GitHub Desktop.
use std::env;
pub fn term_features_has_p() -> bool {
let Ok(value) = env::var("TERM_FEATURES") else {
return false;
};
let mut current = String::new();
for ch in value.chars() {
if !ch.is_ascii_alphanumeric() {
// Stop at first non-alphanumeric per spec
break;
}
if ch.is_ascii_uppercase() {
if current == "P" {
return true;
}
current.clear();
current.push(ch);
} else {
current.push(ch);
}
}
current == "P"
}
fn main() {
if term_features_has_p() {
println!("PROGRESS feature detected");
} else {
println!("PROGRESS feature not detected");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment