Returns `true` if the shell command is primarily reading/searching.
(cmd: &str)
| 374 | |
| 375 | /// Returns `true` if the shell command is primarily reading/searching. |
| 376 | fn is_read_command(cmd: &str) -> bool { |
| 377 | let lower = cmd.to_lowercase(); |
| 378 | |
| 379 | // Only match if the command starts with (or pipes into) a read-like tool |
| 380 | let read_starters = [ |
| 381 | "cat ", |
| 382 | "head ", |
| 383 | "tail ", |
| 384 | "less ", |
| 385 | "more ", |
| 386 | "wc ", |
| 387 | "file ", |
| 388 | "stat ", |
| 389 | "find ", |
| 390 | "fd ", |
| 391 | "rg ", |
| 392 | "grep ", |
| 393 | "ag ", |
| 394 | "ack ", |
| 395 | "ls ", |
| 396 | "tree ", |
| 397 | "git log", |
| 398 | "git show", |
| 399 | "git diff", |
| 400 | "git status", |
| 401 | "git blame", |
| 402 | ]; |
| 403 | |
| 404 | read_starters.iter().any(|p| lower.starts_with(p)) |
| 405 | || lower.starts_with("echo ") && !lower.contains(">>") && !lower.contains(">") |
| 406 | } |
| 407 | |
| 408 | // ============================================================================= |
| 409 | // Summary Generators |
no test coverage detected