Skip to content
This repository has been archived by the owner on Nov 29, 2022. It is now read-only.

Command prompt highlighting does not work #84

Closed
nzkller opened this issue Feb 28, 2020 · 4 comments
Closed

Command prompt highlighting does not work #84

nzkller opened this issue Feb 28, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@nzkller
Copy link

nzkller commented Feb 28, 2020

Hello everybody :)

Description

I have a similar issue as #81 but for me it's not colouring at all.

The regex is ^([^$#(]+)(\$|#|\([^)]+\)#)

The output is to basically color the command prompt
[root@dev ~]$

But when I add the regex to the yml file, respecting the indentation is not working at all

- description: User highlight
  regex: ^([^$#(]+)(\$|#|\([^)]+\)#)
  color: f#ffffff

I have no errors when using CT like ssh 1.1.1.1 | ct but still no colouring the prompt.

I also have version 0.3.4 on my Mac installed via brew and it's working just fine the regex using the old syntax in .chromatermrc

HIGHLIGHT {^([^$#(]+)(\$|#|\([^)]+\)#)} {bold white}

What I might be doing wrong that new regex are not working? because the file is being parsed, when I purposely make a mistake in the syntax, it automatically indicates me when using CT.

The issue I have it in both the server with CentOS 7 and in macOS Catalina

Environment

  • OS: [macOS 10.15.2] Catalina
  • OS: [CentOS Linux release 7.6.1810 (Core)]
  • ChromaTerm: [0.5.8 (pip3 show chromaterm)]

[root@dev ~]$ pip3 show chromaterm
Name: chromaterm
Version: 0.5.8
Summary: Colorize your output using RegEx
Home-page: https://github.com/hSaria/ChromaTerm
Author: hSaria
Author-email: [email protected]
License: MIT
Location: /usr/local/lib/python3.6/site-packages
Requires: psutil, PyYAML

Configuration

[root@dev ~]$ cat .chromaterm.yml
rules:
- description: IPv4
  regex: \b(?<!\.)((25[0-5]|(2[0-4]|[0-1]?\d)?\d)\.){3}(25[0-5]|(2[0-4]|[0-1]?\d)?\d)(/\d+)?(?!\.)\b
  color: f#00ffff

- description: IPv6 (boundaries don't work here as they can be in the start or end of the match, so using lookaheads and lookbehinds instead)
  regex: (?i)((?<=[\W])|^)(?<!:)(([\da-f]{1,4}:){7}[\da-f]{1,4}|([\da-f]{1,4}:){1,1}(:[\da-f]{1,4}){1,6}|([\da-f]{1,4}:){1,2}(:[\da-f]{1,4}){1,5}|([\da-f]{1,4}:){1,3}(:[\da-f]{1,4}){1,4}|([\da-f]{1,4}:){1,4}(:[\da-f]{1,4}){1,3}|([\da-f]{1,4}:){1,5}(:[\da-f]{1,4}){1,2}|([\da-f]{1,4}:){1,6}(:[\da-f]{1,4})|([\da-f]{1,4}:){1,7}:|:((:[\da-f]{1,4}){1,7}|:)|::(ffff(:0{1,4})?:)?((25[0-5]|(2[0-4]|[0-1]?\d)?\d)\.){3}(25[0-5]|(2[0-4]|[0-1]?\d)?\d)|([\da-f]{1,4}:){1,4}:((25[0-5]|(2[0-4]|[0-1]?\d)?\d)\.){3}(25[0-5]|(2[0-4]|[0-1]?\d)?\d))(%[\da-z]+)?(/\d+)?(?!:)((?=[\W])|$)
  color: f#ff00ff

- description: MAC addresses
  regex: (?i)\b((?<!:)([\da-f]{1,2}:){5}[\da-f]{1,2}(?!:)|(?<!\.)([\da-f]{4}\.){2}[\da-f]{4}(?!\.))\b
  color: f#5f61ad

- description: Date in YYYY-MM-DD, YY-MM-DD, MMM (YYYY|DD), or DD MMM (YYYY)? formats
  regex: (?i)((?<=[\W])|^)((\d{2}|\d{4})\-((0)?[1-9]|1[0-2])\-(3[0-1]|([1-2]\d)|(0)?[1-9])|(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s(\d{4}|\s\d|(3[0-1]|([0-2]\d)))|((\d|(3[0-1]|([0-2]\d)))\s(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)(\s\d{4})?))((?=[\WT_])|$)
  color: b#af5f00

- description: Time in hh:mm:ss.SSSSSS format (sec, msec, and nsec optional)
  regex: \b((?<!:)((2[0-3])|[0-1]\d):[0-5]\d(:[0-5]\d)?((\.|,)\d{3,6})?(?!:))\b
  color: b#af5f00

- description: Generics - Bad
  regex: (?i)\b(password|abnormal(ly)?|down|los(t|s|ing)|err(or(s)?)?|(den(y|ies|ied)?)|reject(ing|ed)?|drop(ped|s)?|(err\-)?disable(d)?|(time(d)?(\-)?out)|fail(s|ed|iure)?|disconnect(ed)?|unreachable|invalid|bad|notconnect|unusable|block(ing|ed)?|blk|inaccessible|wrong|collision(s)?|unsynchronized|mismatch|runts|CRC)\b
  color: f#ff0000

- description: Generics - Ambigious bad
  regex: (?i)\b(no(t|pe)?|exit(ed)?|reset((t)?ing)?|discard(ed|ing)?|filter(ed)?|stop(p(ed|ing))?|never|can((')?t|not))\b
  color: f#865e12

- description: Generics - Not too bad
  regex: (?i)\b(warning(s)?)\b
  color: f#ffff00

- description: Generics - Ambigious good
  regex: (?i)\b(ye(s|a(h)?|p)?|started|running|can)\b
  color: f#085e0b

- description: Generics - Good
  regex: (?i)\b(up|ok(ay)?|permit(ed|s)?|accept(s|ed)?|enable(d)?|online|succe((ss(ful|fully)?)|ed(ed)?)?|connect(ed)?|reachable|valid|forwarding|synchronized)\b
  color: f#00ff00

- description: User highlight
  regex: ^([^$#(]+)(\$|#|\([^)]+\)#)
  color: f#ffffff
@hSaria
Copy link
Owner

hSaria commented Feb 28, 2020

This is a side effect following 6e387e7. Let me see what I can do to fix this issue while keeping #83 fixed. It's not highlighting it because, internally, ct is anticipating more data on the line, so coloring it might produce inconsistent results.

@hSaria hSaria changed the title Adding new regex into .chromaterm.yml not working Command prompt highlighting does not work Feb 28, 2020
@hSaria hSaria added the bug Something isn't working label Feb 28, 2020
@hSaria hSaria closed this as completed in da4ea7a Feb 28, 2020
@hSaria
Copy link
Owner

hSaria commented Feb 28, 2020

v0.5.9 released with a fix for this issue. Thanks for submitting it – and with such detail; it really helps improve ChromaTerm :)

@nzkller
Copy link
Author

nzkller commented Feb 29, 2020

@hSaria Thank you very much! it works perfectly!

I would like to thank you for creating ChromaTerm and for making our lives easier and better as network admins.

I'm glad I could help and I tried to be as clear as posible.

Thank you again and best regards

@hSaria
Copy link
Owner

hSaria commented Feb 29, 2020

Glad you like it and thank you for the kind words.

Full disclosure: the original ChromaTerm was written by TunnelsUp, so they also get part of the credit :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants