mirror of https://github.com/garabik/grc.git
Compare commits
141 Commits
Author | SHA1 | Date |
---|---|---|
Radovan Garabík | f4a579e08d | |
Radovan Garabík | c81ae202b1 | |
Radovan Garabík | f79a3dc650 | |
Radovan Garabík | 47e7daa155 | |
Radovan Garabík | 223732e54b | |
Radovan Garabík | ab22533a16 | |
Radovan Garabík | ea4aa18200 | |
Radovan Garabík | 6f0a553c76 | |
Radovan Garabík | d8fc493d72 | |
Radovan Garabík | 09793f88a6 | |
Radovan Garabík | e277b6e960 | |
Radovan Garabík | 1d7de7ea44 | |
Radovan Garabík | cffdc86127 | |
Radovan Garabík | 30ecf4688f | |
Radovan Garabík | db55a51206 | |
Radovan Garabík | 64c1ba6a0d | |
Radovan Garabík | 9dd0d18f62 | |
Radovan Garabík | c367041dcc | |
Radovan Garabík | 4ea874b224 | |
Vitaliy Perekhovy | ae9cecb66c | |
Joeky | b7e96762b4 | |
Radovan Garabík | 06afa277e0 | |
Radovan Garabík | e0c5ab25c8 | |
Radovan Garabík | ca8acefed8 | |
Radovan Garabík | cb0ee756ca | |
Radovan Garabík | acd749e705 | |
Radovan Garabík | 7cd8fff5e1 | |
Radovan Garabík | 357e686aa6 | |
Radovan Garabík | 2fc38520fc | |
Radovan Garabík | 1844de085c | |
Radovan Garabík | 4e796fbb8d | |
hjpotter92 | 7eaacb5c4a | |
Radovan Garabík | a31019fd81 | |
Radovan Garabík | 98f483068a | |
Radovan Garabík | f2ace18191 | |
Radovan Garabík | 61c070db25 | |
Radovan Garabík | ce4f6290d8 | |
Radovan Garabík | eaf4203de1 | |
Radovan Garabík | 8f7adc0eee | |
Radovan Garabík | e969eeef72 | |
Radovan Garabík | 826422fad6 | |
hjpotter92 | 757515996f | |
hjpotter92 | 8eb0e6614b | |
hjpotter92 | 8275543560 | |
Raizo62 | 4cdaaceb3e | |
Raizo62 | ec1eab4f64 | |
Radovan Garabík | 70f4178f37 | |
Adrian Papari | 5ee2461214 | |
Adrian Papari | 5fefb0602f | |
Radovan Garabík | 8f5b15e55a | |
Radovan Garabík | b16ae2647d | |
Radovan Garabík | 371f85a580 | |
Radovan Garabík | 9f61e86374 | |
Radovan Garabík | f7b36ed2c0 | |
Radovan Garabík | 7704a1824e | |
Andrei Buzoianu | 4e1e9d7fdc | |
Andrei Buzoianu | dfb89f2e15 | |
Andrei Buzoianu | 95da0c8e3a | |
Andrei Buzoianu | 3f3fc2932e | |
Andrei Buzoianu | 499fdbff0e | |
Radovan Garabík | 8263f4f63b | |
Radovan Garabík | 8c2a0ace74 | |
Radovan Garabík | e5f43bf3d8 | |
Radovan Garabík | 892c6f6671 | |
Radovan Garabík | 023c88b37b | |
Radovan Garabík | fb14b1a0a0 | |
Wayne Walker | 0c615d2904 | |
Justin J. Novack | f2ec76166e | |
Justin J. Novack | 92e48627f8 | |
Justin J. Novack | a51b7f0a7b | |
Justin J. Novack | 448f19652a | |
Radovan Garabík | 01a21de7fa | |
Radovan Garabík | 7d04c05cd0 | |
Radovan Garabík | 3101bb9eb3 | |
Rostyslav Polishchuk | fba1ba22b5 | |
Radovan Garabík | c910742ee6 | |
Radovan Garabík | 23c1802b4a | |
Raizo62 | 6006304f28 | |
Vincent Milum Jr | f6788db3e1 | |
Vincent Milum Jr | 0a8a163c03 | |
Vincent Milum Jr | 43092396e8 | |
Raizo62 | 1a8a777ee0 | |
Radovan Garabík | 30606591b7 | |
Luis Davim | 77414a6d18 | |
Radovan Garabík | 763fa396b1 | |
Luis Davim | 02f22d4cf4 | |
Radovan Garabík | 01af1fdceb | |
Luis Davim | 36ef164987 | |
Luis Davim | ad91fc4b2e | |
Luis Davim | e83a11599c | |
Luis Davim | 074fe6e3b1 | |
Radovan Garabík | c414dfd3b4 | |
Radovan Garabík | 9367d03d9f | |
Radovan Garabík | 75e255c730 | |
Radovan Garabík | 98b4df7bd2 | |
Radovan Garabík | eafbb9dded | |
Radovan Garabík | 5c9d5abec4 | |
Radovan Garabík | 5981e2ac1c | |
Radovan Garabík | 8267bab647 | |
Radovan Garabík | c71b244b80 | |
Ricardo J. Barberis | ee07d1bd15 | |
Ricardo J. Barberis | 7df059ed67 | |
raizo62 | 270e11cb83 | |
raizo62 | edee9e7591 | |
Dave Wikoff | 9302d75f06 | |
Radovan Garabík | b11c36fcba | |
Radovan Garabík | 5ca81657ab | |
raizo62 | 4a37b7fc7c | |
Radovan Garabík | ae79db506e | |
Radovan Garabík | 677295cb8f | |
Radovan Garabík | b5726877be | |
Radovan Garabík | c7856d4068 | |
Radovan Garabík | f32d8a1432 | |
Miha Frangež | 2b98e0767d | |
Alexander Kapshuna | dd7ecc05d6 | |
Alexander Kapshuna | 3abfc841db | |
Alexander Kapshuna | 7a5f76aeee | |
Radovan Garabík | ae88b81759 | |
Radovan Garabík | c1cb9b8941 | |
Radovan Garabík | 04665c00b5 | |
Radovan Garabík | 50174b2336 | |
Radovan Garabík | 5bc9f4e70f | |
Radovan Garabík | 047bcc6c7a | |
Erik Valdivieso | f3f76ad382 | |
Florian Beer | 918df658c2 | |
Isaias Pina | 1d07328d38 | |
g0tmi1k | 98ec00d036 | |
Radovan Garabík | d64b7c6523 | |
Radovan Garabík | 681408c3a5 | |
Radovan Garabík | e0033c0a23 | |
Radovan Garabík | 8ec2f1a310 | |
Alex Jahraus | d713c4fbce | |
Felix Yan | 692cd20fba | |
Tasnad Kernetzky | fc39736c78 | |
Tasnad Kernetzky | 90de144c31 | |
Tasnad Kernetzky | 66efc0dc3a | |
Isaias Pina | e9fc71c699 | |
Isaias Pina | e88d90ff0a | |
Isaias Pina | 4c8b5a799a | |
Alexander Kapshuna | 9c4796ff65 | |
Radovan Garabík | 375b6c3443 |
|
@ -161,9 +161,9 @@ there can be more attributes per line (separated by space), e.g.
|
|||
|
||||
will display pathnames in bold blinking green
|
||||
|
||||
## Python 3 compatibility
|
||||
## Python 2 & 3 compatibility
|
||||
|
||||
There is some preliminary python3 support, meaning that both grc and grcat will run under both python2 and python3. However, all the regular expressions are strings, and grcat works on string input (not bytes). Therefore it will miserably fail if fed input with invalid UTF-8 characters.
|
||||
both grc and grcat are targetted towards python3 now; there is an attempt at python2 compatibility, meaning that both grc and grcat will run under both python2 and python3. However, all the regular expressions are strings, and grcat works on string input (not bytes).
|
||||
|
||||
## Hints
|
||||
|
||||
|
@ -179,13 +179,16 @@ or, if you have recent BSD tail:
|
|||
|
||||
## Automatic aliases
|
||||
|
||||
You can start using grc automatically with supported commands. The following assumes that `grc.<bashrc|zsh|fish>` is in `/etc`. The location may differ (i. e. `/usr/local/etc` when installed with homebrew).
|
||||
You can start using grc automatically with supported commands. The following assumes that `grc.<sh|zsh|fish>` is in `/etc`. The location may differ (i. e. `/usr/local/etc` when installed with [homebrew](https://formulae.brew.sh/formula/grc)); or the `grc.sh` can be placed into `/etc/profile.d/` (this is in fact the default). Be aware this is somewhat invasive and better test it before deploying.
|
||||
|
||||
### Bash
|
||||
|
||||
To set aliases for supported commands, append to your `~/.bashrc`:
|
||||
|
||||
[[ -s "/etc/grc.bashrc" ]] && source /etc/grc.bashrc
|
||||
GRC_ALIASES=true
|
||||
[[ -s "/etc/profile.d/grc.sh" ]] && source /etc/grc.sh
|
||||
|
||||
If the file `/etc/default/grc` exists, it is sourced first, therefore you can place a line saying `GRC_ALIASES=true` there.
|
||||
|
||||
### ZSH
|
||||
|
||||
|
@ -199,3 +202,11 @@ Add to `~/.config/fish/config.fish` or in a new file in `~/.config/fish/conf.d/`
|
|||
|
||||
source /usr/local/etc/grc.fish
|
||||
|
||||
## Dynamic aliases
|
||||
|
||||
By running the follow code, it will check to see what programs are already installed on your OS (based on your `$PATH`), and echo out the result. This could then be added to your shell resource file as a one off. Alternatively, by removing the `echo` in the code, it could be placed into your shell resource file directly, and it will create the necessarily aliases each time:
|
||||
|
||||
for cmd in g++ gas head make ld ping6 tail traceroute6 $( ls /usr/share/grc/ ); do
|
||||
cmd="${cmd##*conf.}"
|
||||
type "${cmd}" >/dev/null 2>&1 && echo alias "${cmd}"="$( which grc ) --colour=auto ${cmd}"
|
||||
done
|
||||
|
|
2
_grc
2
_grc
|
@ -16,7 +16,7 @@ args=(
|
|||
'(-e --stderr)'{-e,--stderr}'[redirect stderr; do not automatically redirect stdout]'
|
||||
'(-s --stdout)'{-s,--stdout}'[redirect stdout; even with -e/--stderr]'
|
||||
'(-c <name>--config=<name>)'{-c+,--config=-}'[use <name> as configuration file for grcat]:file:_files'
|
||||
'--color=-[colo?urize output]:color:(on off auto)'
|
||||
'--colour=-[colourize output]:colour:(on off auto)'
|
||||
'(-h --help)'{-h,--help}'[display help message and exit]'
|
||||
'--pty[run command in pseudotermnial (experimental)]'
|
||||
'*::arguments:{ _normal }'
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
# Green Words
|
||||
regexp=[Ee]nabled?|[Oo]k|[Rr]unning|[Tt]rue
|
||||
colour=green
|
||||
-
|
||||
# Red Words
|
||||
regexp=[Dd]isabled?|[Ee]rrors?|[Ss]topped|[Ff]alse
|
||||
colour=red
|
||||
-
|
||||
# Yellow Words
|
||||
regexp=[Ww]arning
|
||||
colour=yellow
|
|
@ -0,0 +1,72 @@
|
|||
# curl grc colorizer configuration
|
||||
===
|
||||
# Outgoing Headers
|
||||
regexp=^(>) ([\w\-]+): (.*)
|
||||
colours=default, bright_green, bright_blue, bright_cyan
|
||||
===
|
||||
# Incoming Headers
|
||||
regexp=^(<) ([\w\-]+): (.*)
|
||||
colours=default, bright_yellow, bright_blue, bright_cyan
|
||||
===
|
||||
# Incoming 200
|
||||
regexp=(HTTP/[\d\.]+) 2\d{2} [\w\s]+
|
||||
colours=bright_green on_blue, bright_white on_blue
|
||||
===
|
||||
# Incoming 300
|
||||
regexp=(HTTP/[\d\.]+) 3\d{2}[\w\s]*
|
||||
colours=bright_green on_blue, bright_white on_blue
|
||||
===
|
||||
# Incoming 400
|
||||
regexp=(HTTP/[\d\.]+) 4\d{2} [\w\s]+
|
||||
colours=bright_red on_blue, bright_white on_blue
|
||||
===
|
||||
# Incoming 500
|
||||
regexp=(HTTP/[\d\.]+) 5\d{2} [\w\s]+
|
||||
colours=bright_red on_blue, bright_white on_blue
|
||||
===
|
||||
# Server certificate
|
||||
regexp=\* (Server certificate):
|
||||
colours=magenta, bright_magenta
|
||||
===
|
||||
# Certificate Headers
|
||||
regexp=\* ([a-z][\w\s\d]+): (.*)
|
||||
colours=magenta, bright_blue, bright_cyan
|
||||
===
|
||||
# SSL certificate problem
|
||||
regexp=SSL certificate problem:( .*)
|
||||
colours=bright_red, bright_red
|
||||
===
|
||||
# SSL certificate verify result: self signed certificate (18), continuing anyway.
|
||||
regexp=SSL certificate verify result:(.*)
|
||||
colours=bright_magenta, bright_yellow
|
||||
===
|
||||
# SSL certificate verify ok.
|
||||
regexp=SSL certificate verify (ok)
|
||||
colours=bright_magenta, bright_green
|
||||
===
|
||||
# Verbose Logging
|
||||
regexp=^([{}\*])\s
|
||||
colours=default, bright_magenta
|
||||
count=more
|
||||
===
|
||||
# Outgoing
|
||||
regexp=^>\s
|
||||
colours=bright_green
|
||||
count=more
|
||||
===
|
||||
# Incoming
|
||||
regexp=^<\s
|
||||
colours=bright_yellow
|
||||
count=more
|
||||
===
|
||||
# SSL connection
|
||||
regexp= (SSL connection) using (.*) / (.*)
|
||||
colours=magenta, bright_magenta, bright_magenta, bright_magenta
|
||||
===
|
||||
# Connected to...
|
||||
regexp=(Connected) to (.*) \(([\d\.]+)\) port (\d+)
|
||||
colours=magenta, bright_magenta, bright_magenta, bright_magenta, bright_magenta
|
||||
===
|
||||
# Outgoing METHOD
|
||||
regexp=(GET|HEAD|POST|PUT|DELETE|CONNECT|OPTIONS|TRACE|PATCH) (/.*) HTTP/[\d\.]+
|
||||
colours=bright_white on_blue, bright_white on_blue, bright_yellow on_blue
|
|
@ -4,19 +4,19 @@ regexp=^(?!Filesystem)(\/[-\w\d.]+)+\s
|
|||
colours=blue,bold blue
|
||||
======
|
||||
# Size 'K'
|
||||
regexp=\s\d*[.,]?\dKi?\s
|
||||
regexp=\s\d*[.,]?\d(K|B)i?\s|\b\d{1,3}\b
|
||||
colours=green
|
||||
======
|
||||
# Size 'M'
|
||||
regexp=\s\d*[.,]?\dMi?\s
|
||||
regexp=\s\d*[.,]?\dMi?\s|\b\d{4,6}\b
|
||||
colours=yellow
|
||||
======
|
||||
# Size 'G'
|
||||
regexp=\s\d*[.,]?\dGi?\s
|
||||
regexp=\s\d*[.,]?\dGi?\s|\b\d{7,9}\b
|
||||
colours=red
|
||||
======
|
||||
# Size 'T'
|
||||
regexp=\s\d*[.,]?\dTi?\s
|
||||
regexp=\s\d*[.,]?\dTi?\s|\b\d{10,12}\b
|
||||
colours=bold red
|
||||
======
|
||||
# Mounted on
|
||||
|
@ -24,19 +24,19 @@ regexp=\/$|(\/[-\w\d. ]+)+$
|
|||
colours=green,bold green
|
||||
======
|
||||
# Use 0-60%
|
||||
regexp=[\b1-6][0-9]?%|0%
|
||||
regexp=\s[1-6]?[0-9]%\s
|
||||
colours=green
|
||||
======
|
||||
# Use 70-90%
|
||||
regexp=[7-9][0-9]%
|
||||
# Use 70-89%
|
||||
regexp=\s[78][0-9]%\s
|
||||
colours=yellow
|
||||
======
|
||||
# Use 90-97
|
||||
regexp=9[0-7]%
|
||||
# Use 90-97%
|
||||
regexp=\s9[0-7]%\s
|
||||
colours=red
|
||||
======
|
||||
# Use 98-100
|
||||
regexp=9[8-9]%|100%
|
||||
# Use 98-100%
|
||||
regexp=\s9[89]%|100%\s
|
||||
colours=bold red
|
||||
======
|
||||
# tmpfs lines
|
||||
|
|
|
@ -1,31 +1,23 @@
|
|||
#ipv6
|
||||
regexp=(([0-9a-fA-F]{1,4})?\:\:?[0-9a-fA-F]{1,4})+
|
||||
colours=green
|
||||
=======
|
||||
#time
|
||||
regexp=\s[0-9]{1,6}\s
|
||||
colours=red
|
||||
=======
|
||||
#type
|
||||
regexp=[A-Z]{1,4}
|
||||
colours=cyan
|
||||
=======
|
||||
#in
|
||||
regexp=(IN|CH)
|
||||
colours=yellow
|
||||
=======
|
||||
#domain
|
||||
regexp=[a-z0-9-]+\.
|
||||
colours=magenta
|
||||
=======
|
||||
#ip address
|
||||
regexp=[\S]+\.
|
||||
colours=bright_magenta
|
||||
-
|
||||
#line
|
||||
regexp=^(\S+).*?(\d+)\t(\w+)\t(\w+)\t
|
||||
colours=unchanged,magenta,red,yellow,cyan
|
||||
-
|
||||
#ip4 address
|
||||
regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
|
||||
colours=green
|
||||
=======
|
||||
-
|
||||
#ipv6
|
||||
regexp=\t(([0-9a-fA-F]{1,4})?\:\:?[0-9a-fA-F]{1,4})+
|
||||
colours=dark green
|
||||
-
|
||||
#comments
|
||||
regexp=^;;\s\w*\s*\w*
|
||||
regexp=^;;[\s\w]+
|
||||
colours=yellow
|
||||
=======
|
||||
-
|
||||
#Title
|
||||
regexp=; <<>> DiG (\d+\.\d+\.\d+).*<<>>\s(\S+)$
|
||||
colours=default,green,bold magenta
|
||||
regexp=; <<>> DiG.* <<>> (\S+)
|
||||
colours=default,bold magenta
|
||||
|
|
|
@ -17,9 +17,21 @@ colours=blue
|
|||
# Statuses
|
||||
# https://github.com/docker/docker/blob/e5a3f86e447dd659da3c2e759f3c088a0bfcfe3d/container/state.go#L40
|
||||
# Up
|
||||
regexp=(?:\s{2}|^)(?:Up|Restarting)(?:(?:\s[\w,\d,(,)]+)+)?
|
||||
regexp=(?:\s{2}|^)(?:Up|Restarting)(?:(?:\s[\w,\d]+)+)?
|
||||
colours=bold green
|
||||
======
|
||||
# Health - healthy
|
||||
regexp=\s\(healthy\)
|
||||
colours=bold green
|
||||
======
|
||||
# Health - starting
|
||||
regexp=\s\(health: starting\)
|
||||
colours=bold yellow
|
||||
======
|
||||
# Health - unhealthy
|
||||
regexp=\s\(unhealthy\)
|
||||
colours=bold red
|
||||
======
|
||||
# Statuses - Exited
|
||||
regexp=Exited\s.(\d+).+?(?=\s{2,})
|
||||
colours=bold red,red
|
||||
|
@ -28,9 +40,13 @@ colours=bold red,red
|
|||
regexp=Restarting\s.(\d+).+?(?=\s{2,})
|
||||
colours=bold blue
|
||||
======
|
||||
# Ip Addresses / Ports
|
||||
regexp=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(\:)?(\d{1,5}))?(?:->)?(\d{1,5}(\/)\w+)
|
||||
colours=default,blue,default,bright_green,bright_blue,default
|
||||
# Ip Addresses
|
||||
regexp=(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(\:)?
|
||||
colours=default,blue,default
|
||||
======
|
||||
# Ports
|
||||
regexp=(\d{1,5})?(-)?(\d{1,5})?(->)?(\d{1,5})(-)?(\d{1,5})?(\/)(tcp|udp)
|
||||
colours=default,bright_green,default,bright_green, default, bright_green,default,bright_green,default,cyan
|
||||
======
|
||||
# NAMES
|
||||
regexp=(?:([a-z\-_0-9]+)\/)*([a-z\-_0-9]+)$
|
||||
|
|
|
@ -7,19 +7,31 @@ regexp=\s+[\.\/]+([\w\s\-\_\.]+)(\/.*)?$
|
|||
colours=default,bold blue,blue
|
||||
======
|
||||
# Size 'K'
|
||||
regexp=^\d*[.,]?\dKi?\s
|
||||
regexp=^\d{1,3}\s
|
||||
colours=green
|
||||
======
|
||||
regexp=^ ?\d*[.,]?\dKi?\s
|
||||
colours=green
|
||||
======
|
||||
# Size 'M'
|
||||
regexp=^\d*[.,]?\dMi?\s
|
||||
regexp=^\d{4,6}\s
|
||||
colours=yellow
|
||||
======
|
||||
regexp=^ ?\d*[.,]?\dMi?\s
|
||||
colours=yellow
|
||||
======
|
||||
# Size 'G'
|
||||
regexp=^\d*[.,]?\dGi?\s
|
||||
regexp=^\d{7,9}\s
|
||||
colours=red
|
||||
======
|
||||
regexp=^ ?\d*[.,]?\dGi?\s
|
||||
colours=red
|
||||
======
|
||||
# Size 'T'
|
||||
regexp=^\d*[.,]?\dTi?\s
|
||||
regexp=^\d{10,12}\s
|
||||
colours=bold red
|
||||
======
|
||||
regexp=^ ?\d*[.,]?\dTi?\s
|
||||
colours=bold red
|
||||
======
|
||||
# Total
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
# for testing purposes, do match but do not change anything
|
||||
regexp=([a-g]+)
|
||||
colour=''
|
||||
|
|
@ -1,17 +1,17 @@
|
|||
# Size 'K'
|
||||
regexp=\s\d*[.,]?\dKi?
|
||||
regexp=\s\d*[.,]?\dKi?|\b\d{1,3}\b
|
||||
colours=green
|
||||
======
|
||||
# Size 'M'
|
||||
regexp=\s\d*[.,]?\dMi?
|
||||
regexp=\s\d*[.,]?\dMi?|\b\d{4,6}\b
|
||||
colours=yellow
|
||||
======
|
||||
# Size 'G'
|
||||
regexp=\s\d*[.,]?\dGi?
|
||||
regexp=\s\d*[.,]?\dGi?|\b\d{7,9}\b
|
||||
colours=red
|
||||
======
|
||||
# Size 'T'
|
||||
regexp=\s\d*[.,]?\dTi?
|
||||
regexp=\s\d*[.,]?\dTi?|\b\d{10,12}\b
|
||||
colours=bold red
|
||||
======
|
||||
# Mem
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# go-test grc colorizer configuration
|
||||
regexp==== RUN .*
|
||||
colour=bright_blue
|
||||
-
|
||||
regexp=--- PASS: .* (\(\d+\.\d+s\))
|
||||
colour=green, yellow
|
||||
-
|
||||
regexp=^PASS$
|
||||
colour=bold white on_green
|
||||
-
|
||||
regexp=^(ok|FAIL)\s+.*
|
||||
colour=default, magenta
|
||||
-
|
||||
regexp=--- FAIL: .* (\(\d+\.\d+s\))
|
||||
colour=red, yellow
|
||||
-
|
||||
regexp=^FAIL$
|
||||
colour=bold white on_red
|
||||
-
|
||||
regexp=[^\s]+\.go(:\d+)?
|
||||
colour=cyan
|
|
@ -16,7 +16,7 @@ regexp=\d+(\.\d+)?\s(T|G|M|K|)i?B
|
|||
colours=yellow
|
||||
=======
|
||||
# interface
|
||||
regexp=^([a-z0-9]{2,}\d*):?\s
|
||||
regexp=^([a-z0-9.]{2,}\d*):?\s
|
||||
colours=bold green
|
||||
=======
|
||||
#ip disc
|
||||
|
|
|
@ -3,8 +3,12 @@ regexp=inet\s([^\/]+)\/(\d+)
|
|||
colours=default,bold yellow,bold magenta
|
||||
=====
|
||||
# broadcast
|
||||
regexp=brd\s([^}s]+)
|
||||
colours=default,dark
|
||||
regexp=brd\s([^}\s]+)
|
||||
colours=default,dark cyan
|
||||
=====
|
||||
# dynamic
|
||||
regexp=\bdynamic\b
|
||||
colours=dark green
|
||||
=====
|
||||
# IP6
|
||||
regexp=inet6\s([^\/]+)\/(\d+)
|
||||
|
@ -34,6 +38,10 @@ colours=default,bright_white,bold cyan,cyan
|
|||
regexp=\s<([^>]+)>
|
||||
colours=default,cyan
|
||||
=====
|
||||
# NO-CARRIER
|
||||
regexp=NO-CARRIER
|
||||
colours=bold red
|
||||
=====
|
||||
# Master dev
|
||||
regexp=\smaster\s(\S+)\s
|
||||
colours=default,on_blue white
|
||||
|
|
|
@ -22,6 +22,10 @@ colours=default,magenta,bold magenta
|
|||
regexp=(proto)\s(\S+)\s
|
||||
colours=default,default,dark yellow
|
||||
=====
|
||||
# metric
|
||||
regexp=(metric)\s(\d+)\b
|
||||
colours=default,default,bold white
|
||||
=====
|
||||
# linkdown
|
||||
regexp=linkdown
|
||||
colours=bold red
|
||||
|
|
|
@ -11,7 +11,7 @@ regexp=802\.11([a-z]+)
|
|||
colours=bold yellow
|
||||
=======
|
||||
# Speed
|
||||
regexp=[0-9]+ Mb/s
|
||||
regexp=[0-9\.]+ Mb/s
|
||||
colours=bold yellow
|
||||
=======
|
||||
# Tx-Power
|
||||
|
@ -50,6 +50,10 @@ colours=blue
|
|||
regexp=(?i)mtu(\s|\:)\d+
|
||||
colours=green
|
||||
=======
|
||||
# quality/level/sensitivity
|
||||
regexp=(\d+/\d+)
|
||||
colours=bold yellow
|
||||
=======
|
||||
#errors
|
||||
regexp=errors(\s|\:)\d+
|
||||
colours=red
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
# Green Words
|
||||
regexp=\b(Ready|Running|[Tt]rue|Active|Available|Approved|created)\b
|
||||
colour=unchanged,green
|
||||
-
|
||||
# Master
|
||||
regexp=\smaster\s
|
||||
colour=on_green bold white
|
||||
-
|
||||
# Red Words
|
||||
regexp=\b([Dd]isabled?|[Ee]rrors?|[Ss]topped|[Ff]alse|none|ErrImagePull|[a-zA-Z]+BackOff|OOMKilled|[Tt]erminated|[Ff]aile?d?)\b
|
||||
colour=unchanged,red
|
||||
-
|
||||
# Yellow Words
|
||||
regexp=\b([Ww]arning|[Pp]ending|[Ww]aiting|ContainerCreating|Released|Bound|already exists)\b
|
||||
colour=unchanged,yellow
|
||||
-
|
||||
# Completed Jobs
|
||||
regexp=\b(Completed)\b
|
||||
colour=unchanged,dark green
|
||||
-
|
||||
# Misc IP
|
||||
regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d{1,2})?
|
||||
colour=cyan,magenta
|
||||
-
|
||||
# Ports
|
||||
regexp=(\d+)(:\d+)?/(TCP|UDP)
|
||||
colour=unchanged,yellow,bold green,magenta
|
||||
-
|
||||
# Type/Name
|
||||
regexp=^([^/ ]+)/(\S+)
|
||||
colour=unchanged,yellow,bright_white
|
||||
-
|
||||
# No running Instances
|
||||
regexp=\s(0/[1-9]+)\b
|
||||
colour=unchanged,bold red
|
||||
-
|
||||
# Labels
|
||||
regexp=([\w\d\-_\/.]+)=([\w\d\-_./]+)(,| |$)
|
||||
colour=unchanged,blue,bright_yellow
|
||||
-
|
||||
# YAML First level (PSEUDO)
|
||||
regexp=^([\w\d \-]+):
|
||||
colours=unchanged,bright_blue
|
||||
-
|
||||
# YAML Nested
|
||||
regexp=^[ \-]+(\S+):
|
||||
colours=unchanged, blue
|
||||
-
|
||||
# YAML number
|
||||
regexp=: (\d+)$
|
||||
colours=unchanged, yellow
|
||||
-
|
||||
# Explicit String
|
||||
regexp="(\S*)(?=")
|
||||
colours=default,cyan
|
||||
-
|
||||
# Empy
|
||||
regexp=(\<?[Nn]one\>?|null)
|
||||
colours=magenta
|
||||
-
|
||||
# Events title
|
||||
regexp=\s+(Type)\s+(Reason)\s+(Age)\s+(From)\s+(Message)
|
||||
colours=cyan, cyan, cyan, cyan, cyan, magenta
|
||||
-
|
||||
# Title separator
|
||||
regexp=\s+\-{3,}
|
||||
colours=dark white
|
||||
-
|
||||
# HELP Highlight
|
||||
regexp=( --[^= ]+| -[a-zA-Z]( |,))
|
||||
colour=bright_green
|
||||
-
|
||||
# Higlight (Tested in kubectl config get-contexts)
|
||||
regexp=^\*.+$
|
||||
colour=bold white
|
|
@ -16,14 +16,16 @@ regexp=.*last message repeated \d+ times$
|
|||
colours=yellow
|
||||
count=stop
|
||||
======
|
||||
# this is date
|
||||
regexp=^... (\d| )\d \d\d:\d\d:\d\d(\s[\w\d]+?\s)
|
||||
# this is date and hostname
|
||||
# 'Jun 3 22:44:55 neutronium '
|
||||
# 'Jun 3 22:44:55 neutronium-02.my-domain.io '
|
||||
regexp=^... (\d| )\d \d\d:\d\d:\d\d(\s[-.\w\d]+?\s)
|
||||
colours=green, green, red
|
||||
count=once
|
||||
======
|
||||
# everything in parentheses
|
||||
regexp=\(.+?\)
|
||||
colours=green
|
||||
regexp=\(.*?\)
|
||||
colours=blue
|
||||
count=more
|
||||
======
|
||||
# everything in `'
|
||||
|
@ -31,9 +33,18 @@ regexp=\`.+?\'
|
|||
colours=bold yellow
|
||||
count=more
|
||||
======
|
||||
# everything in "
|
||||
regexp=\".*?\"
|
||||
colours=blue
|
||||
======
|
||||
# this is probably a pathname
|
||||
regexp=/[\w/\.]+
|
||||
colours=bold green
|
||||
regexp=\s/[a-zA-Z_/\.\-\?\d\=\&]+
|
||||
colours=blue
|
||||
count=more
|
||||
======
|
||||
# everything in <>
|
||||
regexp=\<.*?\>
|
||||
colours=blue
|
||||
count=more
|
||||
======
|
||||
# name of process and pid
|
||||
|
@ -41,13 +52,44 @@ regexp=([\w/\.\-]+)(\[\d+?\])
|
|||
colours=bold blue, bold red
|
||||
count=more
|
||||
======
|
||||
# ip number
|
||||
regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
|
||||
colours=bold magenta
|
||||
# IPv4 or IPv4:Port
|
||||
regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(:\d{1,5})?
|
||||
colours=bold yellow
|
||||
count=more
|
||||
======
|
||||
# IPv6
|
||||
regexp=(([0-9a-fA-F]{1,4})?\:\:?[0-9a-fA-F]{1,4})+
|
||||
colours=bold yellow
|
||||
=======
|
||||
# Email address
|
||||
regexp=[a-zA-z0-9\.\-\+]+\@[\w\-\.]+
|
||||
colours=green
|
||||
======
|
||||
# HTTP verbs
|
||||
regexp=GET|POST|PUT|DELETE|PATCH|HEAD
|
||||
colours=green
|
||||
======
|
||||
# 2xx status
|
||||
regexp=\s\b2\d{2}\b\s
|
||||
colours=green
|
||||
======
|
||||
# 3xx status
|
||||
regexp=\s\b3\d{2}\b\s
|
||||
colours=yellow
|
||||
======
|
||||
# 4xx status
|
||||
regexp=\s\b4\d{2}\b\s
|
||||
colours=red
|
||||
======
|
||||
# 5xx status
|
||||
regexp=\s\b5\d{2}\b\s
|
||||
colours=red
|
||||
======
|
||||
# status deferred
|
||||
regexp=status\=deferred|Connection refused
|
||||
colours=red
|
||||
======
|
||||
# connect requires special attention
|
||||
regexp=connect
|
||||
colours=on_red
|
||||
count=more
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ regexp=^(..):(..).(.)
|
|||
colours=default,bright_green,bright_yellow,red
|
||||
-
|
||||
# Ethernet
|
||||
regexp=(Ethernet controller|Network controller)
|
||||
regexp=(Ethernet|Network) controller:
|
||||
colours=cyan
|
||||
-
|
||||
# Wireless
|
||||
|
@ -11,9 +11,26 @@ regexp=Wireless
|
|||
colours=bright_cyan
|
||||
-
|
||||
# SATA
|
||||
regexp=SATA controller
|
||||
regexp=SATA controller:
|
||||
colours=green
|
||||
-
|
||||
# Audio
|
||||
regexp=Audio device
|
||||
regexp=Audio device:
|
||||
colours=blue
|
||||
-
|
||||
# Video
|
||||
regexp=VGA compatible controller:
|
||||
colours=magenta
|
||||
-
|
||||
# Bridges
|
||||
regexp=(PCI|ISA|Host) bridge:
|
||||
colours=red
|
||||
-
|
||||
# any unspecified controller
|
||||
regexp=([A-Z].+?) controller:
|
||||
colours=blue
|
||||
-
|
||||
# For lspci -k
|
||||
regexp=Kernel (?:modules|driver in use): (.+)
|
||||
colours=default,bright_red
|
||||
-
|
||||
|
|
|
@ -27,11 +27,11 @@ regexp=DUP\!
|
|||
colours=red
|
||||
=======
|
||||
# OK
|
||||
regexp=0% packet loss
|
||||
regexp= 0(\.0)?% packet loss
|
||||
colours=green
|
||||
=======
|
||||
# Errors
|
||||
regexp=(Destination Host Unreachable|100% packet loss)
|
||||
regexp=(Destination Host Unreachable|100(\.0)?% packet loss)
|
||||
colours=red
|
||||
=======
|
||||
# unknown host
|
||||
|
|
|
@ -1,12 +1,28 @@
|
|||
# Adapetr
|
||||
regexp=Adapter:\s(.*)
|
||||
colours=default, green
|
||||
# Sensor name
|
||||
regexp=([a-z\-0-9]+)
|
||||
colours=underline yellow
|
||||
======
|
||||
# High temperature
|
||||
regexp=.+:\s+(\+[67][0-9][^0-9])
|
||||
colours=default, red
|
||||
# Data names
|
||||
regexp=(.+:)\s+(.+)
|
||||
colours=unchanged, bright_cyan, default
|
||||
======
|
||||
# Very high temperature
|
||||
regexp=.+:\s+(\+[89][0-9][0-9]?)
|
||||
colours=default, blink red
|
||||
# Extra info
|
||||
regexp=.+\s+(\(.+\))
|
||||
colours=unchanged, bright_black
|
||||
======
|
||||
# Adapter name
|
||||
regexp=Adapter:(\s.*)
|
||||
colours=unchanged, yellow
|
||||
======
|
||||
# Low temperature (below 60)
|
||||
regexp=.+:\s+(\+[2345][0-9]\.[0-9]°C)
|
||||
colours=unchanged, green
|
||||
======
|
||||
# High temperature (above 60)
|
||||
regexp=.+:\s+(\+[67][0-9]\.[0-9]°C)
|
||||
colours=unchanged, bright_yellow
|
||||
======
|
||||
# Very high temperature (above 80)
|
||||
regexp=.+:\s+(\+[89][0-9]\.[0-9]°C)
|
||||
colours=unchanged, bright_red
|
||||
======
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
=======
|
||||
# CAPS LINE
|
||||
regexp=^[A-Z\s%]*([A-Z]{3})[A-Z\s%]*$
|
||||
colours=underline
|
||||
=======
|
||||
# root
|
||||
regexp=^root(?=\s|$)
|
||||
colours=bold red
|
||||
=======
|
||||
# non-root users
|
||||
regexp=^(?:(?!root|USER))([^\s]+)
|
||||
colours=bold yellow,unchanged
|
||||
=======
|
||||
# CMD
|
||||
regexp=^[a-zA-Z]+\w+\s+(\w+)\s+\d+
|
||||
colours=unchanged,bold cyan
|
||||
=======
|
||||
# FD
|
||||
regexp=^[a-zA-Z]+\w+\s+\w+\s+\d+\s+(\d+)
|
||||
colours=unchanged,yellow
|
||||
=======
|
||||
# PID
|
||||
regexp=^[a-zA-Z]+\w+\s+[a-zA-Z]+\w+\s+(\d+)
|
||||
colours=unchanged,bold magenta
|
||||
=======
|
||||
# PROTOCOLS
|
||||
regexp=(tcp4|udp4|tcp6|udp6|stream|dgram)
|
||||
colours=bold blue
|
||||
=======
|
||||
# hostname:service
|
||||
regexp=([\w\.\-]+):([\w\-]+)\b
|
||||
colours=yellow, bold green, bold yellow
|
||||
=======
|
||||
# hostname:port
|
||||
regexp=([\w\.\-]+):(\d+)\b
|
||||
colours=yellow, bold green, bold red
|
||||
=======
|
||||
# *:service
|
||||
regexp=(\*):([\w\-]+)\b
|
||||
colours=yellow, yellow, bold red
|
||||
=======
|
||||
# PATH
|
||||
regexp=\s\/.*\/(\S+)($| \(.*\))
|
||||
colours=green,bright_green,red
|
||||
=======
|
||||
# status
|
||||
regexp=FIN_WAIT.*
|
||||
colours=red
|
||||
=======
|
||||
# status
|
||||
regexp=SYN.*?
|
||||
colours=bold red
|
||||
=======
|
||||
# status
|
||||
regexp=LISTEN(ING)?
|
||||
colours=bold blue
|
||||
=======
|
||||
# status
|
||||
regexp=TIME_WAIT
|
||||
colours=bold red
|
||||
=======
|
||||
# status
|
||||
regexp=CLOS(E(_WAIT)?|ING)
|
||||
colours=red
|
||||
skip=yes
|
||||
=======
|
||||
# status
|
||||
regexp=LAST_ACK
|
||||
colours=red
|
||||
=======
|
||||
# status
|
||||
regexp=ESTAB.*?\b|CONNECTED
|
||||
colours=bold yellow
|
||||
=======
|
||||
# status
|
||||
regexp=FREE
|
||||
colours=bold green
|
||||
=======
|
||||
# status
|
||||
regexp=DISCONNECTING
|
||||
colours=red
|
||||
=======
|
||||
# status
|
||||
regexp=CONNECTING
|
||||
colours=green
|
||||
=======
|
||||
# status
|
||||
regexp=CONNECTING
|
||||
colours=green
|
||||
=======
|
||||
# status
|
||||
regexp=UNKNOWN
|
||||
colours=blink bold red
|
|
@ -1,6 +1,14 @@
|
|||
# Local Address:Port
|
||||
regexp=\s((?:\d+\.){3}\d+|\*|::1?|[\w\d\-\_\.]+):(\S+)\s+\s((?:\d+\.){3}\d+|\*|::1?|[\w\d\-\_\.]+):(\S+)
|
||||
colours=default,bright_green,bright_red,cyan,magenta
|
||||
# status
|
||||
regexp=\[.*\]
|
||||
colours=green
|
||||
=======
|
||||
# Local Address:Port Peer Address:Port
|
||||
regexp=\s((?:\d+\.){3}\d+|\*|\[?[\da-fA-F\.:]+\]?|[\w\d\-\_\.]+)(%[\w\d]+)?:(\S+)\s+\s((?:\d+\.){3}\d+|\*|\[?[\da-fA-F\.:]+\]?|[\w\d\-\_\.]+):(\S+)
|
||||
colours=default,bright_green,blue,bright_red,cyan,magenta
|
||||
=======
|
||||
# process name
|
||||
regexp=\("([^"]+)",
|
||||
colours=blue
|
||||
=======
|
||||
# ipx hostname
|
||||
regexp=^IPX.*[\dABCDEF]+:[\dABCDEF]+
|
||||
|
@ -67,10 +75,6 @@ colours=green
|
|||
regexp=UNKNOWN
|
||||
colours=blink bold red
|
||||
=======
|
||||
# status
|
||||
regexp=\[.*\]
|
||||
colours=green
|
||||
=======
|
||||
# path
|
||||
regexp=(\@)[\dabcdef]+
|
||||
colours=green, bold green
|
||||
|
|
|
@ -24,10 +24,8 @@ regexp=\bDUP
|
|||
colours=red
|
||||
-
|
||||
# !S, !A, !H (host unreachable), etc.
|
||||
regexp=\b\![AFGNPSTU]
|
||||
regexp=\s\!([HNPSFXVC]|\d+)
|
||||
colours=red
|
||||
# just an example:
|
||||
#command=echo 'Network is down'| mail root
|
||||
-
|
||||
# ttl=...!
|
||||
regexp=ttl=\d+\!
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
# Time
|
||||
regexp=\sup(?:\s(\d+ days?),)?\s+(\d+ min|\d+:\d+),
|
||||
colours=default,yellow,green
|
||||
# Regular Up
|
||||
regexp=\sup(?: (\d+) days?,)? +(\d+ min|\d+:\d+)(?=,)
|
||||
colours=green,bold green, bold green
|
||||
-
|
||||
# users
|
||||
regexp=\s+(\d+)\susers
|
||||
regexp=\b(\d+) users?
|
||||
colours=yellow,bold yellow
|
||||
-
|
||||
# load average
|
||||
regexp=load average: (\d+\.\d+),\s(\d+\.\d+),\s(\d+\.\d+)
|
||||
regexp=load average: (\d+[\.,]\d+),\s(\d+[\.,]\d+),\s(\d+[\.,]\d+)
|
||||
colours=default,bright_cyan,cyan,dark cyan
|
||||
-
|
||||
# W Command section
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# Document
|
||||
regexp=---
|
||||
colours=bold yellow
|
||||
-
|
||||
# First level
|
||||
regexp=^(\S+):
|
||||
colours=unchanged,blue
|
||||
-
|
||||
# Nested
|
||||
regexp=^ +(\S+):
|
||||
colours=unchanged,blue
|
||||
-
|
||||
# Set Var
|
||||
regexp=&\S+
|
||||
colours=bold green
|
||||
-
|
||||
# Use Var
|
||||
regexp=\*\S+
|
||||
colours=on_green black
|
||||
-
|
||||
# Array
|
||||
regexp=-\s
|
||||
colours=bold magenta
|
||||
-
|
||||
# << Inheritance
|
||||
regexp=<<
|
||||
colours=bold red
|
||||
-
|
||||
# Explicit String
|
||||
regexp="(\S*)(?=")
|
||||
colours=default,cyan
|
||||
-
|
||||
# Explicit Number
|
||||
regexp= (\d*)$
|
||||
colours=unchanged,yellow
|
|
@ -1,3 +1,31 @@
|
|||
grc (1.13.1-1) unstable; urgency=low
|
||||
|
||||
* fix `ip addr` broadcast colouring
|
||||
|
||||
-- Radovan Garabík <garabik@kassiopeia.juls.savba.sk> Sun, 22 Aug 2021 13:36:39 +0200
|
||||
|
||||
grc (1.13-2) unstable; urgency=medium
|
||||
|
||||
* Source only upload (closes: #983793)
|
||||
|
||||
-- Radovan Garabík <garabik@kassiopeia.juls.savba.sk> Fri, 20 Aug 2021 16:38:48 +0200
|
||||
|
||||
grc (1.13-1) unstable; urgency=low
|
||||
|
||||
* do not add sh aliases unless explicitly allowed in /etc/default/grc
|
||||
(closes: #984629)
|
||||
* several minor improvements
|
||||
|
||||
-- Radovan Garabík <garabik@kassiopeia.juls.savba.sk> Sat, 07 Aug 2021 17:37:55 +0200
|
||||
|
||||
grc (1.12-1) unstable; urgency=low
|
||||
|
||||
* add new configurations
|
||||
* improved zsh alias support
|
||||
* various small bugfixes and improvements
|
||||
|
||||
-- Radovan Garabík <garabik@kassiopeia.juls.savba.sk> Mon, 01 Mar 2021 09:41:35 +0100
|
||||
|
||||
grc (1.11.3-1) unstable; urgency=medium
|
||||
|
||||
* add new configurations
|
||||
|
|
|
@ -1 +1 @@
|
|||
9
|
||||
10
|
||||
|
|
|
@ -2,7 +2,7 @@ Source: grc
|
|||
Section: text
|
||||
Priority: optional
|
||||
Maintainer: Radovan Garabík <garabik@kassiopeia.juls.savba.sk>
|
||||
Standards-Version: 3.9.6
|
||||
Standards-Version: 4.5.1
|
||||
Build-Depends: debhelper (>=9), python3, dh-python
|
||||
|
||||
Package: grc
|
||||
|
|
|
@ -16,7 +16,10 @@ The original source can be found at:
|
|||
|
||||
It is released under GPL v2 or any later version, under Debian
|
||||
systems see /usr/share/common-licenses/GPL-2,
|
||||
with following additional condition:
|
||||
and I have nothing against adding following additional condition (this is
|
||||
however not the part of the license, which remains GPL v2 or any later
|
||||
version):
|
||||
|
||||
If you want to use, redistribute, modify, abuse and molest grc in any
|
||||
way, and you feel like it, you may add any clause to the license, as
|
||||
long as it does not put any additional responsibility for behaviour of
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
# add colourifying aliases for sh and bash shells
|
||||
# true or false
|
||||
#
|
||||
# since this is rather invasive, it defaults to false
|
||||
#
|
||||
# changing it makes your shell source /etc/profile.d/grc
|
||||
|
||||
GRC_ALIASES=false
|
||||
|
|
@ -19,8 +19,6 @@ install:
|
|||
|
||||
# Add here commands to install the package into debian/tmp.
|
||||
./install.sh `pwd`/debian/grc/usr `pwd`/debian/grc
|
||||
# this is too invasive, would be incluided in a next major version
|
||||
rm `pwd`/debian/grc/etc/profile.d/grc.bashrc
|
||||
|
||||
build: build-arch build-indep
|
||||
build-arch: build-stamp
|
||||
|
@ -39,18 +37,18 @@ binary-indep: build install
|
|||
dh_testroot
|
||||
# dh_installdebconf
|
||||
dh_installdocs
|
||||
dh_installexamples
|
||||
dh_installmenu
|
||||
# dh_installexamples
|
||||
# dh_installmenu
|
||||
# dh_installemacsen
|
||||
# dh_installpam
|
||||
# dh_installinit
|
||||
dh_installcron
|
||||
dh_installinit
|
||||
# dh_installcron
|
||||
dh_installman grc.1 grcat.1
|
||||
dh_installinfo
|
||||
# dh_installinfo
|
||||
# dh_undocumented
|
||||
dh_installchangelogs
|
||||
dh_link
|
||||
dh_strip
|
||||
# dh_strip
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
# You may want to make some executables suid here.
|
||||
|
|
42
grc
42
grc
|
@ -6,11 +6,11 @@ import os, re, string, sys, getopt, signal
|
|||
|
||||
|
||||
def version():
|
||||
print ("Generic Colouriser 1.11.3")
|
||||
print ("Generic Colouriser 1.13")
|
||||
sys.exit()
|
||||
|
||||
def help():
|
||||
print("""Generic Colouriser 1.11.3
|
||||
print("""Generic Colouriser 1.13
|
||||
grc [options] command [args]
|
||||
Options:
|
||||
-e --stderr redirect stderr. If this option is selected,
|
||||
|
@ -26,7 +26,6 @@ Options:
|
|||
def catch_signal(signum, frame):
|
||||
"catch signal sent to grc and forward it to the original application"
|
||||
global pidp
|
||||
# print('signal')
|
||||
try:
|
||||
os.kill(pidp, signum)
|
||||
except OSError: # if the subprocess already died
|
||||
|
@ -81,38 +80,33 @@ if stdoutf == 1:
|
|||
if use_pty:
|
||||
import pty
|
||||
|
||||
conffile = None
|
||||
if cfile == "":
|
||||
home = os.environ.get('HOME')
|
||||
xdg = os.environ.get('XDG_CONFIG_HOME')
|
||||
if not xdg and home:
|
||||
xdg = home + '/.config'
|
||||
|
||||
conffilenames = []
|
||||
conffilenames = ['/etc/grc.conf', '/usr/local/etc/grc.conf']
|
||||
if xdg:
|
||||
conffilenames += [xdg + '/grc/grc.conf']
|
||||
if home:
|
||||
conffilenames += [home + '/.grc/grc.conf']
|
||||
conffilenames += ['/usr/local/etc/grc.conf', '/etc/grc.conf']
|
||||
for i in conffilenames:
|
||||
# test if conffile exists, it can be also a pipe
|
||||
if os.path.exists(i) and not os.path.isdir(i):
|
||||
conffile = i
|
||||
break
|
||||
regexplist = []
|
||||
|
||||
if conffile:
|
||||
f = open(conffile, "r")
|
||||
while 1:
|
||||
l = f.readline()
|
||||
if l == "":
|
||||
break
|
||||
if l[0] == "#" or l[0] == '\012':
|
||||
continue
|
||||
regexp = l.strip()
|
||||
if re.search(regexp, ' '.join(args)):
|
||||
cfile = f.readline().strip()
|
||||
break
|
||||
for conffile in conffilenames:
|
||||
# test if conffile exists, it can be also a pipe
|
||||
if os.path.exists(conffile) and not os.path.isdir(conffile):
|
||||
f = open(conffile, "r")
|
||||
while 1:
|
||||
l = f.readline()
|
||||
if l == "":
|
||||
break
|
||||
if l[0] == "#" or l[0] == '\012':
|
||||
continue
|
||||
regexp = l.strip()
|
||||
if re.search(regexp, ' '.join(args)):
|
||||
cfile = f.readline().strip()
|
||||
break
|
||||
|
||||
|
||||
signal.signal(signal.SIGINT, catch_signal)
|
||||
|
||||
|
|
2
grc.1
2
grc.1
|
@ -13,7 +13,7 @@ with optional parameters
|
|||
.I "[args]"
|
||||
piping its stdout or stderr into
|
||||
.BR grcat ",
|
||||
with apropriate configuration file.
|
||||
with appropriate configuration file.
|
||||
|
||||
Configuration file for
|
||||
.BR grc
|
||||
|
|
572
grc.conf
572
grc.conf
|
@ -1,3 +1,295 @@
|
|||
# configure command
|
||||
^([/\w\.]+\/)?configure\b
|
||||
conf.configure
|
||||
|
||||
# ping command
|
||||
^([/\w\.]+\/)?(io|o|n|h|arp|l2)?ping[236]?\b
|
||||
conf.ping
|
||||
|
||||
# traceroute command
|
||||
^([/\w\.]+\/)?traceroute6?\b
|
||||
conf.traceroute
|
||||
|
||||
# gcc command
|
||||
^([/\w\.]+\/)?(g?cc|[gc]\+\+)\s
|
||||
conf.gcc
|
||||
|
||||
# make command
|
||||
^([/\w\.]+\/)?g?make\b
|
||||
conf.gcc
|
||||
|
||||
# netstat command
|
||||
^([/\w\.]+\/)?netstat\b
|
||||
conf.netstat
|
||||
|
||||
# stat command
|
||||
^([/\w\.]+\/)?stat\b
|
||||
conf.stat
|
||||
|
||||
# ss command
|
||||
^([/\w\.]+\/)?ss\b
|
||||
conf.ss
|
||||
|
||||
# diff command
|
||||
^([/\w\.]+\/)?diff\b
|
||||
conf.diff
|
||||
|
||||
# wdiff command
|
||||
^([/\w\.]+\/)?wdiff\b
|
||||
conf.wdiff
|
||||
|
||||
# last/who command
|
||||
^([/\w\.]+\/)?(lastb?|who|lastlog)\b
|
||||
conf.last
|
||||
|
||||
# ldap tools
|
||||
^([/\w\.]+\/)?ldap\b
|
||||
conf.ldap
|
||||
|
||||
# cvs command
|
||||
^([/\w\.]+\/)?cvs\b
|
||||
conf.cvs
|
||||
|
||||
# mount command
|
||||
^([/\w\.]+\/)?mount\b
|
||||
conf.mount
|
||||
|
||||
# findmnt command
|
||||
^([/\w\.]+\/)?findmnt\b
|
||||
conf.findmnt
|
||||
|
||||
# mtr command
|
||||
^([/\w\.]+\/)?mtr\b
|
||||
conf.mtr
|
||||
|
||||
# ps command
|
||||
^([/\w\.]+\/)?ps\b
|
||||
conf.ps
|
||||
|
||||
# dig command
|
||||
^([/\w\.]+\/)?dig\b
|
||||
conf.dig
|
||||
|
||||
# ifconfig command
|
||||
^([/\w\.]+\/)?ifconfig\b
|
||||
conf.ifconfig
|
||||
|
||||
# ls command
|
||||
^([/\w\.]+\/)?ls\s
|
||||
conf.ls
|
||||
|
||||
# mount
|
||||
^([/\w\.]+\/)?mount\b
|
||||
conf.mount
|
||||
|
||||
# df
|
||||
^([/\w\.]+\/)?df\b
|
||||
conf.df
|
||||
|
||||
# du
|
||||
^([/\w\.]+\/)?du\b
|
||||
conf.du
|
||||
|
||||
# ip addr/link
|
||||
^([/\w\.]+\/)?ip( -\w+)* a(d(d(r(e(ss?)?)?)?)?)?\b
|
||||
conf.ipaddr
|
||||
|
||||
^([/\w\.]+\/)?ip( -\w+)* l(i(nk?)?)?\b
|
||||
conf.ipaddr
|
||||
|
||||
# ip route
|
||||
^([/\w\.]+\/)?ip( -\w+)* r(o(u(te?)?)?)?\b
|
||||
conf.iproute
|
||||
|
||||
# ip neighbor
|
||||
^([/\w\.]+\/)?ip( -\w+)* n(e(i(g(h(b(o(ur?)?)?)?)?)?)?)?\b
|
||||
conf.ipneighbor
|
||||
|
||||
# ip command - rest of commands
|
||||
^([/\w\.]+\/)?ip\b
|
||||
conf.ip
|
||||
|
||||
# env
|
||||
^([/\w\.]+\/)?env\b
|
||||
conf.env
|
||||
|
||||
# systemctl show
|
||||
^([/\w\.]+\/)?systemctl show\b
|
||||
conf.env
|
||||
|
||||
# iptables
|
||||
^([/\w\.]+\/)?iptables\b
|
||||
conf.iptables
|
||||
|
||||
# lspci
|
||||
^([/\w\.]+\/)?lspci\b
|
||||
conf.lspci
|
||||
|
||||
# lsblk
|
||||
^([/\w\.]+\/)?lsblk\b
|
||||
conf.lsblk
|
||||
|
||||
# lsof
|
||||
^([/\w\.]+\/)?lsof\b
|
||||
conf.lsof
|
||||
|
||||
# blkid
|
||||
^([/\w\.]+\/)?blkid\b
|
||||
conf.blkid
|
||||
|
||||
# id
|
||||
^([/\w\.]+\/)?id\b
|
||||
conf.id
|
||||
|
||||
# iostat / sar
|
||||
^([/\w\.]+\/)?(iostat|sar)\b
|
||||
conf.iostat_sar
|
||||
|
||||
# fdisk
|
||||
^([/\w\.]+\/)?fdisk -l\b
|
||||
conf.fdisk
|
||||
|
||||
# free
|
||||
^([/\w\.]+\/)?free\b
|
||||
conf.free
|
||||
|
||||
------------
|
||||
# docker
|
||||
|
||||
# docker ps
|
||||
^([/\w\.]+\/)?docker(-compose)? ps\b
|
||||
conf.dockerps
|
||||
|
||||
^([/\w\.]+\/)?docker image(s| ls| list)\b
|
||||
conf.dockerimages
|
||||
|
||||
^([/\w\.]+\/)?docker search\b
|
||||
conf.dockersearch
|
||||
|
||||
#^([/\w\.]+\/)?docker pull\b
|
||||
#conf.dockerpull
|
||||
|
||||
^([/\w\.]+\/)?docker-machine ls\b
|
||||
conf.docker-machinels
|
||||
|
||||
^([/\w\.]+\/)?docker network ls\b
|
||||
conf.dockernetwork
|
||||
|
||||
^([/\w\.]+\/)?docker info\b
|
||||
conf.dockerinfo
|
||||
|
||||
^([/\w\.]+\/)?docker version\b
|
||||
conf.dockerversion
|
||||
------------
|
||||
|
||||
# journalctl command
|
||||
^([/\w\.]+\/)?journalctl\b
|
||||
conf.log
|
||||
|
||||
# KubeCTL
|
||||
^([/\w\.]+\/)?kubectl((?!edit|exec|run|go-template).)*$
|
||||
conf.kubectl
|
||||
|
||||
# sensors command
|
||||
^([/\w\.]+\/)?sensors\b
|
||||
conf.sensors
|
||||
|
||||
# systemctl command
|
||||
^([/\w\.]+\/)?systemctl\b
|
||||
conf.systemctl
|
||||
|
||||
# sysctl command
|
||||
^([/\w\.]+\/)?sysctl\b
|
||||
conf.sysctl
|
||||
|
||||
# tcpdump command
|
||||
^([/\w\.]+\/)?tcpdump\b
|
||||
conf.tcpdump
|
||||
|
||||
# tune2fs command
|
||||
^([/\w\.]+\/)?tune2fs\b
|
||||
conf.tune2fs
|
||||
|
||||
# lsmod
|
||||
^([/\w\.]+\/)?lsmod\b
|
||||
conf.lsmod
|
||||
|
||||
# lsattr
|
||||
^([/\w\.]+\/)?lsattr\b
|
||||
conf.lsattr
|
||||
|
||||
# semanage ---------------------------------
|
||||
^([/\w\.]+\/)?semanage boolean\b
|
||||
conf.semanageboolean
|
||||
^([/\w\.]+\/)?semanage fcontext\b
|
||||
conf.semanagefcontext
|
||||
^([/\w\.]+\/)?semanage (user|login|port)\b
|
||||
conf.semanageuser
|
||||
|
||||
# getsebool
|
||||
^([/\w\.]+\/)?getsebool\b
|
||||
conf.getsebool
|
||||
|
||||
# ulimit
|
||||
^([/\w\.]+\/)?ulimit\b
|
||||
conf.ulimit
|
||||
|
||||
# vmstat
|
||||
^([/\w\.]+\/)?vmstat\b
|
||||
conf.vmstat
|
||||
|
||||
# dnf
|
||||
^([/\w\.]+\/)?dnf\b
|
||||
conf.dnf
|
||||
|
||||
# nmap
|
||||
^([/\w\.]+\/)?nmap\b
|
||||
conf.nmap
|
||||
|
||||
# uptime | w
|
||||
^([/\w\.]+\/)?(uptime|w)\b
|
||||
conf.uptime
|
||||
|
||||
# getfacl
|
||||
^([/\w\.]+\/)?getfacl\b
|
||||
conf.getfacl
|
||||
|
||||
# ntpdate
|
||||
^([/\w\.]+\/)?ntpdate\b
|
||||
conf.ntpdate
|
||||
|
||||
# showmount
|
||||
^([/\w\.]+\/)?showmount\b
|
||||
conf.showmount
|
||||
|
||||
# apache ant command
|
||||
^([/\w\.]+\/)?ant\b
|
||||
conf.ant
|
||||
|
||||
# # apache maven command
|
||||
^([/\w\.]+\/)?mvn\b
|
||||
conf.mvn
|
||||
|
||||
# iwconfig command
|
||||
^([/\w\.]+\/)?iwconfig\b
|
||||
conf.iwconfig
|
||||
|
||||
# lolcat command
|
||||
^([/\w\.]+\/)?lolcat\b
|
||||
conf.lolcat
|
||||
|
||||
# whois
|
||||
^([/\w\.]+\/)?whois\b
|
||||
conf.whois
|
||||
|
||||
# go test
|
||||
^([/\w\.]+\/)?go test\b
|
||||
conf.go-test
|
||||
|
||||
# sockstat command
|
||||
^([/\w\.]+\/)?sockstat\b
|
||||
conf.sockstat
|
||||
|
||||
# anything to do with irc
|
||||
\b\w+\b.*irc.*
|
||||
conf.irclog
|
||||
|
@ -6,284 +298,4 @@ conf.irclog
|
|||
\b\w+\b.*log\b
|
||||
conf.log
|
||||
|
||||
# configure command
|
||||
(^|[/\w\.]+/)?configure
|
||||
conf.configure
|
||||
|
||||
# ping command
|
||||
(^|[/\w\.]+/)(io|o|n|h|arp|l2)?ping[236]?\s
|
||||
conf.ping
|
||||
|
||||
# traceroute command
|
||||
(^|[/\w\.]+/)traceroute6?\s
|
||||
conf.traceroute
|
||||
|
||||
# gcc command
|
||||
(^|[/\w\.]+/)(g?cc|[gc]\+\+)\s
|
||||
conf.gcc
|
||||
|
||||
# make command
|
||||
(^|[/\w\.]+/)g?make\s?
|
||||
conf.gcc
|
||||
|
||||
# netstat command
|
||||
(^|[/\w\.]+/)netstat\s?
|
||||
conf.netstat
|
||||
|
||||
# stat command
|
||||
(^|[/\w\.]+/)stat\s?
|
||||
conf.stat
|
||||
|
||||
# ss command
|
||||
(^|[/\w\.]+/)ss\s?
|
||||
conf.ss
|
||||
|
||||
# diff command
|
||||
(^|[/\w\.]+/)diff\s?
|
||||
conf.diff
|
||||
|
||||
# wdiff command
|
||||
(^|[/\w\.]+/)wdiff\s?
|
||||
conf.wdiff
|
||||
|
||||
# last/who command
|
||||
(^|[/\w\.]+/)(lastb?|who|lastlog)\b
|
||||
conf.last
|
||||
|
||||
# ldap tools
|
||||
(^|[/\w\.]+/)ldap
|
||||
conf.ldap
|
||||
|
||||
# cvs command
|
||||
(^|[/\w\.]+/)cvs\s?
|
||||
conf.cvs
|
||||
|
||||
# mount command
|
||||
(^|[/\w\.]+/)mount\s?
|
||||
conf.mount
|
||||
|
||||
# findmnt command
|
||||
(^|[/\w\.]+/)findmnt\s?
|
||||
conf.findmnt
|
||||
|
||||
# mtr command
|
||||
(^|[/\w\.]+/)mtr\s?
|
||||
conf.mtr
|
||||
|
||||
# ps command
|
||||
(^|[/\w\.]+/)ps\s?
|
||||
conf.ps
|
||||
|
||||
# dig command
|
||||
(^|[/\w\.]+/)dig\s?
|
||||
conf.dig
|
||||
|
||||
# ifconfig command
|
||||
(^|[/\w\.]+/)ifconfig\s?
|
||||
conf.ifconfig
|
||||
|
||||
# ls command
|
||||
(^|[/\w\.]+/)ls\s
|
||||
conf.ls
|
||||
|
||||
# mount
|
||||
(^|[/\w\.]+/)mount\s?
|
||||
conf.mount
|
||||
|
||||
# df
|
||||
(^|[/\w\.]+/)df\s?
|
||||
conf.df
|
||||
|
||||
# du
|
||||
(^|[/\w\.]+/)du\s?
|
||||
conf.du
|
||||
|
||||
# ip addr/link
|
||||
(^|[/\w\.]+/)ip a(ddr)*\s?
|
||||
conf.ipaddr
|
||||
|
||||
(^|[/\w\.]+/)ip ?(-.)* ?l(ink)*\s?
|
||||
conf.ipaddr
|
||||
|
||||
# ip route
|
||||
(^|[/\w\.]+/)ip r(oute)*\s?
|
||||
conf.iproute
|
||||
|
||||
# ip neighbor
|
||||
(^|[/\w\.]+/)ip n(eighbor)*\s?
|
||||
conf.ipneighbor
|
||||
|
||||
# ip command - rest of commands
|
||||
(^|[/\w\.]+/)ip?\s
|
||||
conf.ip
|
||||
|
||||
# env
|
||||
(^|[/\w\.]+/)env\s?
|
||||
conf.env
|
||||
|
||||
# systemctl show
|
||||
(^|[/\w\.]+/)systemctl show\s?
|
||||
conf.env
|
||||
|
||||
# iptables
|
||||
(^|[/\w\.]+/)iptables\s?
|
||||
conf.iptables
|
||||
|
||||
# lspci
|
||||
(^|[/\w\.]+/)lspci\s?
|
||||
conf.lspci
|
||||
|
||||
# lsblk
|
||||
(^|[/\w\.]+/)lsblk\s?
|
||||
conf.lsblk
|
||||
|
||||
# lsof
|
||||
(^|[/\w\.]+/)lsof\s?
|
||||
conf.lsof
|
||||
|
||||
# blkid
|
||||
(^|[/\w\.]+/)blkid\s?
|
||||
conf.blkid
|
||||
|
||||
# id
|
||||
(^|[/\w\.]+/)id\s?
|
||||
conf.id
|
||||
|
||||
# iostat / sar
|
||||
(^|[/\w\.]+/)(iostat|sar)\s?
|
||||
conf.iostat_sar
|
||||
|
||||
# fdisk
|
||||
(^|[/\w\.]+/)fdisk -l\s?
|
||||
conf.fdisk
|
||||
|
||||
# free
|
||||
(^|[/\w\.]+/)free\s?
|
||||
conf.free
|
||||
|
||||
# findmnt
|
||||
(^|[/\w\.]+/)findmnt\s?
|
||||
conf.findmnt
|
||||
|
||||
------------
|
||||
# docker
|
||||
|
||||
# docker ps
|
||||
(^|[/\w\.]+/)docker(-compose)? ps\s?
|
||||
conf.dockerps
|
||||
|
||||
(^|[/\w\.]+/)docker images\s?
|
||||
conf.dockerimages
|
||||
|
||||
(^|[/\w\.]+/)docker search\s?
|
||||
conf.dockersearch
|
||||
|
||||
#(^|[/\w\.]+/)docker pull\s?
|
||||
#conf.dockerpull
|
||||
|
||||
(^|[/\w\.]+/)docker-machine ls\s?
|
||||
conf.docker-machinels
|
||||
|
||||
(^|[/\w\.]+/)docker network ls\s?
|
||||
conf.dockernetwork
|
||||
|
||||
(^|[/\w\.]+/)docker info\s?
|
||||
conf.dockerinfo
|
||||
|
||||
(^|[/\w\.]+/)docker version\s?
|
||||
conf.dockerversion
|
||||
------------
|
||||
|
||||
# journalctl command
|
||||
(^|[/\w\.]+/)journalctl?\s
|
||||
conf.log
|
||||
|
||||
# systemctl command
|
||||
(^|[/\w\.]+/)systemctl?\s
|
||||
conf.systemctl
|
||||
|
||||
# sysctl command
|
||||
(^|[/\w\.]+/)sysctl?\s
|
||||
conf.sysctl
|
||||
|
||||
# tcpdump command
|
||||
(^|[/\w\.]+/)tcpdump\s?
|
||||
conf.tcpdump
|
||||
|
||||
# tune2fs command
|
||||
(^|[/\w\.]+/)tune2fs\s?
|
||||
conf.tune2fs
|
||||
|
||||
# lsmod
|
||||
(^|[/\w\.]+/)lsmod\s?
|
||||
conf.lsmod
|
||||
|
||||
# lsattr
|
||||
(^|[/\w\.]+/)lsattr\s?
|
||||
conf.lsattr
|
||||
|
||||
# semanage ---------------------------------
|
||||
(^|[/\w\.]+/)semanage boolean\s?
|
||||
conf.semanageboolean
|
||||
(^|[/\w\.]+/)semanage fcontext\s?
|
||||
conf.semanagefcontext
|
||||
(^|[/\w\.]+/)semanage (user|login|port)\s?
|
||||
conf.semanageuser
|
||||
|
||||
# getsebool
|
||||
(^|[/\w\.]+/)getsebool\s?
|
||||
conf.getsebool
|
||||
|
||||
# ulimit
|
||||
(^|[/\w\.]+/)ulimit\s?
|
||||
conf.ulimit
|
||||
|
||||
# vmstat
|
||||
(^|[/\w\.]+/)vmstat\s?
|
||||
conf.vmstat
|
||||
|
||||
# dnf
|
||||
(^|[/\w\.]+/)dnf\s?
|
||||
conf.dnf
|
||||
|
||||
# nmap
|
||||
(^|[/\w\.]+/)nmap\s?
|
||||
conf.nmap
|
||||
|
||||
# uptime | w
|
||||
(^|[/\w\.]+/)(uptime|w)\b
|
||||
conf.uptime
|
||||
|
||||
# getfacl
|
||||
(^|[/\w\.]+/)getfacl\s?
|
||||
conf.getfacl
|
||||
|
||||
# ntpdate
|
||||
(^|[/\w\.]+/)ntpdate\s?
|
||||
conf.ntpdate
|
||||
|
||||
# showmount
|
||||
(^|[/\w\.]+/)showmount\s?
|
||||
conf.showmount
|
||||
|
||||
# apache ant command
|
||||
(^|[/\w\.]+/)ant\s?
|
||||
conf.ant
|
||||
|
||||
# # apache maven command
|
||||
(^|[/\w\.]+/)mvn\s?
|
||||
conf.mvn
|
||||
|
||||
# iwconfig command
|
||||
(^|[/\w\.]+/)iwconfig\s?
|
||||
conf.iwconfig
|
||||
|
||||
|
||||
# lolcat command
|
||||
(^|[/\w\.]+/)lolcat\s?
|
||||
conf.lolcat
|
||||
|
||||
# whois
|
||||
(^|[/\w\.]+/)whois\s?
|
||||
conf.whois
|
||||
|
||||
|
|
4
grc.fish
4
grc.fish
|
@ -8,10 +8,10 @@
|
|||
|
||||
set -U grc_plugin_execs cat cvs df diff dig gcc g++ ls ifconfig \
|
||||
make mount mtr netstat ping ps tail traceroute \
|
||||
wdiff blkid du dnf docker docker-machine env id ip iostat \
|
||||
wdiff blkid du dnf docker docker-compose docker-machine env id ip iostat journalctl kubectl \
|
||||
last lsattr lsblk lspci lsmod lsof getfacl getsebool ulimit uptime nmap \
|
||||
fdisk findmnt free semanage sar ss sysctl systemctl stat showmount \
|
||||
tcpdump tune2fs vmstat w who
|
||||
tcpdump tune2fs vmstat w who sockstat
|
||||
|
||||
for executable in $grc_plugin_execs
|
||||
if type -q $executable
|
||||
|
|
|
@ -1,14 +1,25 @@
|
|||
# aliases for grc(1)
|
||||
|
||||
# this will execute only if there is a line with
|
||||
# GRC_ALIASES=true
|
||||
# in /etc/default/grc or you export GRC_ALIASES=true prior to sourcing this
|
||||
|
||||
[ -f /etc/default/grc ] && . /etc/default/grc
|
||||
|
||||
[ x$GRC_ALIASES = xtrue ] || return 0
|
||||
|
||||
GRC="$(which grc)"
|
||||
if [ "$TERM" != dumb ] && [ -n "$GRC" ]; then
|
||||
alias colourify="$GRC -es --colour=auto"
|
||||
if tty -s && [ -n "$TERM" ] && [ "$TERM" != dumb ] && [ -n "$GRC" ]; then
|
||||
alias colourify="$GRC -es"
|
||||
alias blkid='colourify blkid'
|
||||
alias configure='colourify ./configure'
|
||||
alias df='colourify df'
|
||||
alias diff='colourify diff'
|
||||
alias docker='colourify docker'
|
||||
alias docker-compose='colourify docker-compose'
|
||||
alias docker-machine='colourify docker-machine'
|
||||
alias du='colourify du'
|
||||
alias env='colourify env'
|
||||
# alias env='colourify env'
|
||||
alias free='colourify free'
|
||||
alias fdisk='colourify fdisk'
|
||||
alias findmnt='colourify findmnt'
|
||||
|
@ -20,6 +31,8 @@ if [ "$TERM" != dumb ] && [ -n "$GRC" ]; then
|
|||
alias iptables='colourify iptables'
|
||||
alias as='colourify as'
|
||||
alias gas='colourify gas'
|
||||
alias journalctl='colourify journalctl'
|
||||
alias kubectl='colourify kubectl'
|
||||
alias ld='colourify ld'
|
||||
#alias ls='colourify ls'
|
||||
alias lsof='colourify lsof'
|
||||
|
@ -27,6 +40,7 @@ if [ "$TERM" != dumb ] && [ -n "$GRC" ]; then
|
|||
alias lspci='colourify lspci'
|
||||
alias netstat='colourify netstat'
|
||||
alias ping='colourify ping'
|
||||
alias ss='colourify ss'
|
||||
alias traceroute='colourify traceroute'
|
||||
alias traceroute6='colourify traceroute6'
|
||||
alias head='colourify head'
|
||||
|
@ -38,5 +52,6 @@ if [ "$TERM" != dumb ] && [ -n "$GRC" ]; then
|
|||
alias semanage='colourify semanage'
|
||||
alias getsebool='colourify getsebool'
|
||||
alias ifconfig='colourify ifconfig'
|
||||
alias sockstat='colourify sockstat'
|
||||
fi
|
||||
|
131
grc.zsh
131
grc.zsh
|
@ -1,40 +1,95 @@
|
|||
if [[ "$TERM" != dumb ]] && (( $+commands[grc] )) ; then
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
# Supported commands
|
||||
cmds=(
|
||||
cc \
|
||||
configure \
|
||||
cvs \
|
||||
df \
|
||||
diff \
|
||||
dig \
|
||||
gcc \
|
||||
gmake \
|
||||
ifconfig \
|
||||
last \
|
||||
ldap \
|
||||
ls \
|
||||
make \
|
||||
mount \
|
||||
mtr \
|
||||
netstat \
|
||||
ping \
|
||||
ping6 \
|
||||
ps \
|
||||
traceroute \
|
||||
traceroute6 \
|
||||
wdiff \
|
||||
whois \
|
||||
iwconfig \
|
||||
);
|
||||
|
||||
# Set alias for available commands.
|
||||
for cmd in $cmds ; do
|
||||
if (( $+commands[$cmd] )) ; then
|
||||
alias $cmd="grc --colour=auto $(whence $cmd)"
|
||||
fi
|
||||
done
|
||||
|
||||
# Clean up variables
|
||||
unset cmds cmd
|
||||
if ! tty -s || [ ! -n "$TERM" ] || [ "$TERM" = dumb ] || (( ! $+commands[grc] ))
|
||||
then
|
||||
return
|
||||
fi
|
||||
|
||||
# Supported commands
|
||||
cmds=(
|
||||
as
|
||||
ant
|
||||
blkid
|
||||
cc
|
||||
configure
|
||||
curl
|
||||
cvs
|
||||
df
|
||||
diff
|
||||
dig
|
||||
dnf
|
||||
docker
|
||||
docker-compose
|
||||
docker-machine
|
||||
du
|
||||
env
|
||||
fdisk
|
||||
findmnt
|
||||
free
|
||||
g++
|
||||
gas
|
||||
gcc
|
||||
getfacl
|
||||
getsebool
|
||||
gmake
|
||||
id
|
||||
ifconfig
|
||||
iostat
|
||||
ip
|
||||
iptables
|
||||
iwconfig
|
||||
journalctl
|
||||
kubectl
|
||||
last
|
||||
ldap
|
||||
lolcat
|
||||
ld
|
||||
ls
|
||||
lsattr
|
||||
lsblk
|
||||
lsmod
|
||||
lsof
|
||||
lspci
|
||||
make
|
||||
mount
|
||||
mtr
|
||||
mvn
|
||||
netstat
|
||||
nmap
|
||||
ntpdate
|
||||
php
|
||||
ping
|
||||
ping6
|
||||
proftpd
|
||||
ps
|
||||
sar
|
||||
semanage
|
||||
sensors
|
||||
showmount
|
||||
sockstat
|
||||
ss
|
||||
stat
|
||||
sysctl
|
||||
systemctl
|
||||
tcpdump
|
||||
traceroute
|
||||
traceroute6
|
||||
tune2fs
|
||||
ulimit
|
||||
uptime
|
||||
vmstat
|
||||
wdiff
|
||||
whois
|
||||
)
|
||||
|
||||
# Set alias for available commands.
|
||||
for cmd in $cmds ; do
|
||||
if (( $+commands[$cmd] )) ; then
|
||||
$cmd() {
|
||||
grc --colour=auto ${commands[$0]} "$@"
|
||||
}
|
||||
fi
|
||||
done
|
||||
|
||||
# Clean up variables
|
||||
unset cmds cmd
|
||||
|
|
44
grcat
44
grcat
|
@ -4,6 +4,34 @@ from __future__ import print_function
|
|||
|
||||
import sys, os, string, re, signal, errno
|
||||
|
||||
|
||||
# redefine readline to pass invalidly encoded characters unchanged, if possible
|
||||
if hasattr(sys.stdin, 'reconfigure') and hasattr(sys.stdout, 'reconfigure'):
|
||||
# at least python3.7
|
||||
sys.stdin.reconfigure(errors='surrogateescape')
|
||||
sys.stdout.reconfigure(errors='surrogateescape')
|
||||
myreadline = sys.stdin.readline
|
||||
myprint = print
|
||||
else:
|
||||
if hasattr(sys.stdin, 'buffer'):
|
||||
# python3
|
||||
buffer_reader = sys.stdin.buffer
|
||||
else:
|
||||
buffer_reader = sys.stdin
|
||||
def myreadline():
|
||||
for line in buffer_reader:
|
||||
try:
|
||||
decoded = line.decode('utf-8', errors='surrogateescape')
|
||||
except (UnicodeDecodeError, LookupError):
|
||||
decoded = line.decode('utf-8', errors='ignore')
|
||||
return decoded
|
||||
return ''
|
||||
def myprint(x):
|
||||
try:
|
||||
print(x)
|
||||
except UnicodeEncodeError:
|
||||
print(x.encode('utf-8', errors='replace').decode('utf-8'))
|
||||
|
||||
#some default definitions
|
||||
colours = {
|
||||
'none' : "",
|
||||
|
@ -175,9 +203,9 @@ while not is_last:
|
|||
prevcolour = colours['default']
|
||||
prevcount = "more"
|
||||
blockflag = 0
|
||||
freadline = sys.stdin.readline
|
||||
|
||||
while 1:
|
||||
line = freadline()
|
||||
line = myreadline()
|
||||
if line == "" :
|
||||
break
|
||||
if line[-1] in '\r\n':
|
||||
|
@ -187,14 +215,15 @@ while 1:
|
|||
for pattern in regexplist:
|
||||
pos = 0
|
||||
currcount = pattern['count']
|
||||
was_replace = 0 # watch replacements, replace regexp only one per line, to avoid infinte loops if the replacement matches the regexp again
|
||||
while 1:
|
||||
m = pattern['regexp'](line, pos)
|
||||
if m:
|
||||
if 'replace' in pattern:
|
||||
if was_replace:
|
||||
break
|
||||
line = re.sub(m.re, pattern['replace'], line)
|
||||
#m = pattern['regexp'](line, pos)
|
||||
#if not m:
|
||||
# break
|
||||
was_replace = 1
|
||||
if 'colours' in pattern:
|
||||
if currcount == "block":
|
||||
blockflag = 1
|
||||
|
@ -235,7 +264,8 @@ while 1:
|
|||
skip = pattern['skip'] in ("yes", "1", "true")
|
||||
if 'colours' not in pattern:
|
||||
break
|
||||
else: break
|
||||
else:
|
||||
break
|
||||
if m and currcount == "stop":
|
||||
prevcount = "stop"
|
||||
break
|
||||
|
@ -273,7 +303,7 @@ while 1:
|
|||
clineprev = cline[i]
|
||||
nline = nline + colours['default']
|
||||
try:
|
||||
print(nline)
|
||||
myprint(nline)
|
||||
except IOError as e:
|
||||
if e.errno == errno.EPIPE:
|
||||
break
|
||||
|
|
|
@ -24,7 +24,7 @@ cp -fv grc.conf $CONFDIR
|
|||
cp -fv grc.zsh $CONFDIR
|
||||
cp -fv grc.fish $CONFDIR
|
||||
mkdir -p $PROFILEDIR
|
||||
cp -fv grc.bashrc $PROFILEDIR
|
||||
cp -fv grc.sh $PROFILEDIR
|
||||
|
||||
# probably we should not install it into site-functions in a debian package...
|
||||
if [ "$PREFIX" = "/usr/local" ]; then
|
||||
|
|
Loading…
Reference in New Issue