mirror of https://github.com/garabik/grc.git
Merge branch 'master' of github.com:garabik/grc
This commit is contained in:
commit
c887a9c8f6
3
README
3
README
|
@ -234,3 +234,6 @@ If you have GNU tail:
|
|||
or, if you have recent BSD tail:
|
||||
tail -F /var/log/syslog | grcat conf.log >/dev/tty12
|
||||
|
||||
If you want to start using grc automatically with supported commands, add
|
||||
source /etc/grc.bashrc
|
||||
to your .bash_profile (assuming you copied grc.bashrc to /etc)
|
||||
|
|
10
conf.df
10
conf.df
|
@ -3,23 +3,23 @@ regexp=^.*?\s
|
|||
colours=green
|
||||
======
|
||||
# Size 'K'
|
||||
regexp=\s\d*[.,]?\dK\s
|
||||
regexp=\s\d*[.,]?\dKi?\s
|
||||
colours=green
|
||||
======
|
||||
# Size 'M'
|
||||
regexp=\s\d*[.,]?\dM\s
|
||||
regexp=\s\d*[.,]?\dMi?\s
|
||||
colours=yellow
|
||||
======
|
||||
# Size 'G'
|
||||
regexp=\s\d*[.,]?\dG\s
|
||||
regexp=\s\d*[.,]?\dGi?\s
|
||||
colours=red
|
||||
======
|
||||
# Size 'T'
|
||||
regexp=\s\d*[.,]?\dT\s
|
||||
regexp=\s\d*[.,]?\dTi?\s
|
||||
colours=bold red
|
||||
======
|
||||
# Mounted on
|
||||
regexp=/\w*
|
||||
regexp=/[-\w\d./]*
|
||||
colours=bold green
|
||||
======
|
||||
# Use 0-60%
|
||||
|
|
|
@ -16,7 +16,7 @@ regexp=\d+(\.\d+)?\s(T|G|M|K|)i?B
|
|||
colours=yellow
|
||||
=======
|
||||
# interface
|
||||
regexp=^(([a-z]{3,}\d*)|lo)\s
|
||||
regexp=^([a-z0-9]{2,}\d*):?\s
|
||||
colours=bold green
|
||||
=======
|
||||
#ip disc
|
||||
|
@ -24,7 +24,7 @@ regexp=(inet6?|netmask|broadcast)
|
|||
colours=cyan
|
||||
=======
|
||||
#flags
|
||||
regexp=(?<=[,<])[^,]*(?=[,>])
|
||||
regexp=(?<=[,<])[^,]+?(?=[,>])
|
||||
colours=blue
|
||||
=======
|
||||
# mtu
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
grc (1.8-1) unstable; urgency=low
|
||||
|
||||
* added support for Ki, Gi, Ti for df (thanks to Juraj Bednár)
|
||||
* added example aliases for bash (thanks to Juraj Bednár)
|
||||
* fix infinite loop if regexp matches but does not consume anything
|
||||
|
||||
-- Radovan Garabík <garabik@kassiopeia.juls.savba.sk> Mon, 16 Mar 2015 14:38:42 +0100
|
||||
|
||||
grc (1.7-1) unstable; urgency=low
|
||||
|
||||
* added `replace' keyword to replace arbitrary text (idea by Ben Hoskins)
|
||||
|
|
4
grc
4
grc
|
@ -3,11 +3,11 @@
|
|||
import os, re, string, sys, getopt, signal
|
||||
|
||||
def version():
|
||||
print ("Generic Colouriser 1.7")
|
||||
print ("Generic Colouriser 1.8rc")
|
||||
sys.exit()
|
||||
|
||||
def help():
|
||||
print("""Generic Colouriser 1.7
|
||||
print("""Generic Colouriser 1.8rc
|
||||
grc [options] command [args]
|
||||
Options:")
|
||||
-e --stderr redirect stderr. If this option is selected,
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
GRC=`which grc`
|
||||
if [ "$TERM" != dumb ] && [ -n "$GRC" ]
|
||||
then
|
||||
alias colourify="$GRC -es --colour=auto"
|
||||
alias configure='colourify ./configure'
|
||||
alias diff='colourify diff'
|
||||
alias make='colourify make'
|
||||
alias gcc='colourify gcc'
|
||||
alias g++='colourify g++'
|
||||
alias as='colourify as'
|
||||
alias gas='colourify gas'
|
||||
alias ld='colourify ld'
|
||||
alias netstat='colourify netstat'
|
||||
alias ping='colourify ping'
|
||||
alias traceroute='colourify /usr/sbin/traceroute'
|
||||
alias head='colourify head'
|
||||
alias tail='colourify tail'
|
||||
alias dig='colourify dig'
|
||||
alias mount='colourify mount'
|
||||
alias ps='colourify ps'
|
||||
alias mtr='colourify mtr'
|
||||
alias df='colourify df'
|
||||
fi
|
15
grcat
15
grcat
|
@ -87,6 +87,10 @@ conffile = None
|
|||
if 'HOME' in os.environ:
|
||||
home = [os.environ['HOME']+"/.grc/"]
|
||||
conffilepath = [""] + home + ["/usr/local/share/grc/", "/usr/share/grc/"]
|
||||
if len(sys.argv) != 2:
|
||||
sys.stderr.write("You are not supposed to call grcat directly, but the usage is: grcat conffile\n")
|
||||
sys.exit(1)
|
||||
|
||||
conffile_arg = sys.argv[1] # tentative conffile
|
||||
for i in conffilepath:
|
||||
if os.path.isfile(i+conffile_arg):
|
||||
|
@ -154,7 +158,8 @@ while 1:
|
|||
line = freadline()
|
||||
if line == "" :
|
||||
break
|
||||
line = line[:-1]
|
||||
if line[-1] in '\r\n':
|
||||
line = line[:-1]
|
||||
clist = []
|
||||
skip = 0
|
||||
for pattern in regexplist:
|
||||
|
@ -185,7 +190,13 @@ while 1:
|
|||
break
|
||||
if currcount == "more":
|
||||
prevcount = "more"
|
||||
pos = m.end(0)
|
||||
newpos = m.end(0)
|
||||
# special case, if the regexp matched but did not consume anything,
|
||||
# advance the position by 1 to escape endless loop
|
||||
if newpos == pos:
|
||||
pos += 1
|
||||
else:
|
||||
pos = newpos
|
||||
else:
|
||||
prevcount = "once"
|
||||
pos = len(line)
|
||||
|
|
Loading…
Reference in New Issue