-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.rc
143 lines (114 loc) · 2.88 KB
/
functions.rc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/sh
# protect against sourcing if zaje cannot be found.
if command -v zaje > /dev/null 2>&1 ; then
# An example for how you can wrap common utils so that their output is filtered through zaje.
# Usage:
# - Adjust this so it points to the lexers dir
# export ZAJE_SYNDIR=/path/to/syntax_files
# - Source this in your shell by running " . /path/to/functions.rc".
# You can of course add this to ~/.bashrc or any other file sourced by your shell.
# Any Bourne comptable shell will work, BASH is not a requirement.
# - Invoke `tail` and `diff` as you normally would. You should get highlighted output:)
# alias cat=zaje
# alias history='history |zaje -d -l history'
tail()
{
BIN="tail"
LEXER="server-log"
# uncomment this to apply it to only specific types of files
#FILE=$(echo "$@" | awk -F " " '{print $NF}')
#if echo $FILE | grep -q nginx || echo $FILE | grep -q apache;then
#fi
if [ "$1" = "-f" ];then
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l "$LEXER" -
else
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l "$LEXER"
fi
}
diff()
{
BIN="diff"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l $BIN
}
lsb_release()
{
BIN="lsb_release"
if command -v "$BIN" > /dev/null 2>&1 ;then
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l yaml
fi
}
ping()
{
BIN="ping"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l $BIN -
}
route()
{
BIN="route"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l $BIN
}
traceroute()
{
BIN="traceroute"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l $BIN -
}
nmap()
{
BIN="nmap"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l $BIN -
}
netstat()
{
BIN="netstat"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l $BIN
}
ifconfig()
{
BIN="ifconfig"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l $BIN
}
ip()
{
BIN="ip"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l $BIN
}
ss()
{
BIN="ss"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje
}
df()
{
BIN="df"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l $BIN
}
du()
{
BIN="du"
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l $BIN
}
xmllint()
{
BIN=xmllint
if which $BIN > /dev/null ;then
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l xml
else
echo "$BIN does not exist"
fi
}
jsonlint()
{
BIN=jsonlint
if which $BIN > /dev/null ;then
$(which $BIN --skip-alias --skip-functions) "$@" | zaje -l json
else
echo "$BIN does not exist"
fi
}
apt_cache()
{
$(which apt-cache) "$@" | zaje -l apt
}
else
echo "Couldn't find zaje. Exiting without sourcing functions"
fi