Skip to content

Commit

Permalink
Support parenthesis in process highlighter
Browse files Browse the repository at this point in the history
  • Loading branch information
bensadeh committed Jan 14, 2024
1 parent db2bdac commit 0797326
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog
## 2.5.0

## 3.0.0

- Process highlighter has updated default styling and matches processes with parenthesis


## 2.4.0
Expand Down
2 changes: 1 addition & 1 deletion example-logs/example1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Sun Aug 14 10:51:19.272 INFO _handleLinkEvent: WiFi is not powered. Resetting s
Sun Aug 14 10:51:19.316 DEBUG Usb Host Notification Error Apple80211Set: Device power is off seqNum 17 Total 4 chg 1 en0
Sun Aug 14 10:51:22.602 DEBUG sharingd (542) is not entitled for com.apple.wifi.join_history, will not allow request

Jan 02 21:14:54 innodellix systemd[1]: Started Accounts Service.
Jan 02 21:14:54 innodellix (udev-worker)[1]: Started Accounts Service.
Jan 02 21:14:54 innodellix systemd[1]: Started Rule-based Manager for Device Events and Files.
Jan 02 21:14:54 innodellix systemd[1]: Stopped libvirtd-config.service: Deactivated successfully.
Jan 02 21:14:54 innodellix systemd[1]: Finished Libvirt Virtual Machine Management Daemon - configuration.
Expand Down
6 changes: 3 additions & 3 deletions src/highlighters/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::types::Highlight;
use nu_ansi_term::Style;
use once_cell::sync::Lazy;
use regex::Regex;

static PROCESS_REGEX: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(?P<process_name>[\w-]+)\[(?P<process_num>\d+)\]").expect("Invalid regex pattern"));
static PROCESS_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"(?P<process_name>\([^)]+\)|[\w-]+)\[(?P<process_num>\d+)]").expect("Invalid regex pattern")
});

pub struct ProcessHighlighter {
process_name: Style,
Expand Down
6 changes: 3 additions & 3 deletions src/theme/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ impl Default for Time {
impl Default for Process {
fn default() -> Self {
Process {
name: Style::new().fg(Color::Green),
id: Style::new().fg(Color::Red),
separator: Style::new().fg(Color::Yellow),
name: Style::new().fg(Color::Yellow),
id: Style::new().fg(Color::Cyan),
separator: Style::new().fg(Color::Red),
disabled: false,
}
}
Expand Down

0 comments on commit 0797326

Please sign in to comment.