color_echo 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/bin/color_echo +51 -209
- data/bin/lib/display.rb +212 -0
- data/lib/color_echo/const.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 955540738b14db7f9f1fd1bda47f1892cdd31f2d
|
4
|
+
data.tar.gz: caa4d7f6549be7b4727de5e9cb7b8e4e1f3ef53a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e99e1abe31a23a058cfe7c999a9893b8ad73d2d10b31e2a9e622d71b971b8fe3ada618e5b83ce4ed756bf41d80b97c41d8f9b67065ce45e08a780e65e3341b1
|
7
|
+
data.tar.gz: a014dd348b0de49c1bf768b5305ec20c61594e9f5dcc0e894c9cdef8f7b6188c01722401d766ad4476646462e7db78579c63ec1e2b3adf3c6d2d2039cf817388
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@ Decorate the command line output with ANSI escape sequence.
|
|
3
3
|
Text that is output by "print, puts, p" method is decorated.
|
4
4
|
It is also can to decorate only your specified words!
|
5
5
|
|
6
|
-
Version: 1.
|
6
|
+
Version: 1.1.0
|
7
7
|
Compliant Rubys Version: 2.0.0, 2.1.0 (for Linux)
|
8
8
|
License: MIT
|
9
9
|
Gems repository: http://rubygems.org/gems/color_echo
|
@@ -308,7 +308,12 @@ puts "Disable rainbow mode."
|
|
308
308
|
![screen shot](/images/screenshot.png)
|
309
309
|
|
310
310
|
## Release Note
|
311
|
-
* v1.
|
311
|
+
* v1.1.0, 2014-01-27
|
312
|
+
* Modified to output the argument when the standard input is hit.
|
313
|
+
* Add --stripe option in the command line interface.
|
314
|
+
* Change the delimiter of long option with a hyphen -> -symbol-list,--index-list; Can to specify also underscore as before.
|
315
|
+
|
316
|
+
* v1.0.0, 2014-01-23
|
312
317
|
* Add command line interface.
|
313
318
|
|
314
319
|
* v0.9.0, 2014-01-19
|
data/bin/color_echo
CHANGED
@@ -10,248 +10,76 @@ def require_color_echo_get
|
|
10
10
|
#require_relative "../lib/color_echo/get"
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
require_color_echo
|
13
|
+
require_relative "./lib/display"
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def usage
|
21
|
-
require_color_echo
|
22
|
-
|
23
|
-
CE.once.ch :yellow
|
24
|
-
puts <<-EOS
|
25
|
-
|
26
|
-
#{CE::LIBS_NAME} - #{CE::SUMMARY}
|
27
|
-
VERSION: #{CE::VERSION}
|
28
|
-
README: #{CE::DOCS_PAGE}
|
29
|
-
|
30
|
-
EOS
|
31
|
-
|
32
|
-
padding = " " * 4
|
33
|
-
headers = ["* Usage", "* Options", "* Example"]
|
34
|
-
headers_op = [
|
35
|
-
"-v:", "--symbol_list:", "--index_list:", "--pickup word [--pickup word ...]:", "--fg color_name:", "--bg color_name:",
|
36
|
-
"--tx text_attribute[,...]:", "--watch:", "-n:", "-h:"
|
37
|
-
]
|
38
|
-
CE.pickup(headers, :h_green)
|
39
|
-
CE.pickup(headers_op, :cyan)
|
40
|
-
|
41
|
-
puts padding + "* Usage"
|
42
|
-
|
43
|
-
CE.ch :h_blue
|
44
|
-
puts padding * 2 + "color_echo [options] text"
|
45
|
-
puts padding * 2 + "color_echo [options] < /path/to/file"
|
46
|
-
puts padding * 2 + "echo text | color_echo [options]"
|
47
|
-
puts padding * 2 + "color_echo -v"
|
48
|
-
puts padding * 2 + "color_echo -s"
|
49
|
-
puts padding * 2 + "color_echo -l"
|
50
|
-
puts padding * 2 + "color_echo -h" + $/ + $/
|
51
|
-
CE.off :fg
|
52
|
-
|
53
|
-
puts padding + "* Options"
|
54
|
-
|
55
|
-
puts padding * 2 + "-v:"
|
56
|
-
puts padding * 3 + "Display version of color_echo." + $/ + $/
|
57
|
-
|
58
|
-
puts padding * 2 + "--symbol_list:"
|
59
|
-
puts padding * 3 + "Display symbol list that can to specify."
|
60
|
-
puts padding * 3 + "short option is -s." + $/ + $/
|
61
|
-
|
62
|
-
puts padding * 2 + "--index_list:"
|
63
|
-
puts padding * 3 + "Display color index list that can to specify."
|
64
|
-
puts padding * 3 + "short option is -l." + $/ + $/
|
65
|
-
|
66
|
-
puts padding * 2 + "--pickup word [--pickup word ...]:"
|
67
|
-
puts padding * 3 + "Decorate your specified wrods. You can use this option any number of times."
|
68
|
-
puts padding * 3 + "Regular expressions can be used; like that -> /^foo/i"
|
69
|
-
puts padding * 3 + "short option is -p." + $/ + $/
|
70
|
-
|
71
|
-
puts padding * 2 + "--fg color_name:"
|
72
|
-
puts padding * 3 + "Decorate the foreground color."
|
73
|
-
puts padding * 3 + "short option is -f." + $/ + $/
|
74
|
-
|
75
|
-
puts padding * 2 + "--bg color_name:"
|
76
|
-
puts padding * 3 + "Decorate the background color."
|
77
|
-
puts padding * 3 + "short option is -b." + $/ + $/
|
78
|
-
|
79
|
-
puts padding * 2 + "--tx text_attribute[,...]:"
|
80
|
-
puts padding * 3 + "Decorate the text attribute."
|
81
|
-
puts padding * 3 + "short option is -t." + $/ + $/
|
82
|
-
|
83
|
-
puts padding * 2 + "--watch:"
|
84
|
-
puts padding * 3 + "Interactive mode. Break word is -> exit, quit, bye; Or Ctl + c"
|
85
|
-
puts padding * 3 + "short option is -w." + $/ + $/
|
86
|
-
|
87
|
-
puts padding * 2 + "-n:"
|
88
|
-
puts padding * 3 + "Do not output the trailing newline." + $/ + $/
|
89
|
-
|
90
|
-
puts padding * 2 + "-h:"
|
91
|
-
puts padding * 3 + "Show this message." + $/ + $/
|
92
|
-
|
93
|
-
puts padding + "* Example"
|
94
|
-
|
95
|
-
CE.once.ch :h_magenta
|
96
|
-
puts padding * 2 + %(* color_echo can to highlight even when you following the log file by tailf, tail -f.)
|
97
|
-
puts padding * 3 + %(tailf /var/log/httpd/access_log | color_echo -w -p "127.0.0.1" -t bold)
|
98
|
-
puts padding * 3 + %(tailf /var/log/php/php_error.log | color_echo -w -p "foo.php" -p "Fatal error:" -f h_blue) + $/ + $/
|
99
|
-
|
100
|
-
CE.once.ch :h_magenta
|
101
|
-
puts padding * 2 + %(* color_echo is useful to read the access log, etc.)
|
102
|
-
puts padding * 3 + %(cat /var/log/httpd/access_log | color_echo -p "Sun Jan 18" -f h_cyan -t underscore | less)
|
103
|
-
puts padding * 3 + %(color_echo -p "Sun Jan 18" -f h_cyan -t underscore < /var/log/httpd/access_log | less)
|
104
|
-
puts padding * 3 + %((color_echo -f cyan -p /\\\\s2..\\\\s/ | color_echo -f h_red -p /\\\\s5..\\\\s/ | less) < /var/log/httpd/access_log)
|
105
|
-
puts padding * 3 + %(sed -n 1,1000p /var/log/httpd/access_log | color_echo -f cyan -p /\\\\s2..\\\\s/ | color_echo -f h_red -p /\\\\s5..\\\\s/ | less) + $/ + $/
|
106
|
-
|
107
|
-
CE.once.ch :h_magenta
|
108
|
-
puts padding * 2 + %(* It is a simple to use.)
|
109
|
-
puts padding * 3 + %(color_echo Hello\\!\\! -f h_white -b index199)
|
110
|
-
puts padding * 3 + %(color_echo Hello\\!\\! -t blink,bold -f magenta) + $/ + $/
|
111
|
-
|
112
|
-
CE.once.ch :h_magenta
|
113
|
-
puts padding * 2 + %(* color_echo can receive the standard input.)
|
114
|
-
puts padding * 3 + %(echo FooFoOfOO | color_echo -t reverse_video)
|
115
|
-
puts padding * 3 + %(echo FooFoOfOO | color_echo -f index130 -p /foo$/i | color_echo -f index180 -p /^foo/i)
|
116
|
-
puts padding * 3 + %(netstat -na | color_echo -p ":80" | color_echo -p "127.0.0.1" -f h_cyan) + $/ + $/
|
117
|
-
|
118
|
-
exit 0
|
119
|
-
end
|
120
|
-
|
121
|
-
def display_color_index
|
122
|
-
require_color_echo
|
123
|
-
|
124
|
-
CE.rainbow
|
125
|
-
cnt = 134
|
126
|
-
padding = " " * 2
|
127
|
-
mes = "OK, Let me check color index list... :)"
|
128
|
-
puts padding + "-" * cnt
|
129
|
-
puts padding + " " * ((cnt - mes.size)/2) + mes
|
130
|
-
puts padding + "-" * cnt
|
131
|
-
|
132
|
-
print padding
|
133
|
-
256.times do |i|
|
134
|
-
num = i + 1
|
135
|
-
CE.fg "index#{num}".intern
|
136
|
-
print "index#{num}" + " " * (4 - num.to_s.size)
|
137
|
-
CE.bg "index#{num}".intern
|
138
|
-
print " " * 5
|
139
|
-
CE.off
|
140
|
-
print " " * 3
|
141
|
-
|
142
|
-
if num % 8 == 0
|
143
|
-
print $/ + $/
|
144
|
-
print padding if num != 256
|
145
|
-
end
|
146
|
-
end
|
147
|
-
CE.off
|
148
|
-
|
149
|
-
exit 0
|
150
|
-
end
|
151
|
-
|
152
|
-
def display_symbol_list
|
153
|
-
require_color_echo
|
154
|
-
|
155
|
-
symbols_color = [
|
156
|
-
:black,
|
157
|
-
:gray,
|
158
|
-
:red,
|
159
|
-
:h_red,
|
160
|
-
:green,
|
161
|
-
:h_green,
|
162
|
-
:yellow,
|
163
|
-
:h_yellow,
|
164
|
-
:blue,
|
165
|
-
:h_blue,
|
166
|
-
:magenta,
|
167
|
-
:h_magenta,
|
168
|
-
:cyan,
|
169
|
-
:h_cyan,
|
170
|
-
:white,
|
171
|
-
:h_white
|
172
|
-
]
|
173
|
-
symbols_text_attr = [
|
174
|
-
:bold,
|
175
|
-
:underscore,
|
176
|
-
:blink,
|
177
|
-
:reverse_video,
|
178
|
-
:concealed
|
179
|
-
]
|
180
|
-
|
181
|
-
CE.times(3).rainbow
|
182
|
-
cnt = 60
|
183
|
-
padding = " " * 2
|
184
|
-
mes = "OK, Let me check color name list... :)"
|
185
|
-
puts padding + "-" * cnt
|
186
|
-
puts padding + " " * ((cnt - mes.size)/2) + mes
|
187
|
-
puts padding + "-" * cnt
|
188
|
-
|
189
|
-
header_colors = "* foreground or background colors"
|
190
|
-
header_text_attrs = "* text attributes"
|
191
|
-
CE.pickup([header_colors, header_text_attrs], :cyan, nil, [:underscore, :bold])
|
192
|
-
|
193
|
-
puts padding + header_colors
|
194
|
-
symbols_color.each do |color_name|
|
195
|
-
CE.off(:bg).fg color_name
|
196
|
-
print "#{padding*2}:#{color_name}" + " " * (11 - color_name.to_s.size)
|
197
|
-
CE.bg color_name
|
198
|
-
puts color_name.to_s + " " * (30 - color_name.to_s.size)
|
199
|
-
end
|
200
|
-
|
201
|
-
CE.off [:bg, :fg]
|
202
|
-
print $/ + $/
|
15
|
+
def output_interactive
|
16
|
+
output_stripe_interactive if @is_stripe
|
203
17
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
puts
|
18
|
+
while input = STDIN.gets
|
19
|
+
input.chomp!
|
20
|
+
exit 0 if @exit_words.index(input)
|
21
|
+
eval(@code_decorate)
|
22
|
+
puts CE.get(input)
|
209
23
|
end
|
210
|
-
|
211
|
-
print $/
|
212
|
-
|
213
|
-
exit 0
|
214
24
|
end
|
215
25
|
|
216
|
-
def
|
217
|
-
|
26
|
+
def output_stripe_interactive
|
27
|
+
cnt = 0
|
218
28
|
while input = STDIN.gets
|
219
29
|
input.chomp!
|
220
|
-
exit 0 if exit_words.index(input)
|
221
|
-
eval(@code_decorate)
|
30
|
+
exit 0 if @exit_words.index(input)
|
31
|
+
eval(@code_decorate) if cnt % 2 == 0
|
222
32
|
puts CE.get(input)
|
33
|
+
cnt += 1
|
223
34
|
end
|
224
35
|
end
|
225
36
|
|
226
37
|
def output(target)
|
38
|
+
output_stripe(target) if @is_stripe
|
39
|
+
|
227
40
|
eval(@code_decorate)
|
228
41
|
begin
|
229
42
|
print CE.get(target)
|
230
43
|
rescue Errno::EPIPE
|
231
44
|
end
|
45
|
+
exit 0
|
46
|
+
end
|
47
|
+
|
48
|
+
def output_stripe(target)
|
49
|
+
cnt = 0
|
50
|
+
target.split($/).each do |record|
|
51
|
+
eval(@code_decorate) if cnt % 2 == 0
|
52
|
+
puts CE.get(record)
|
53
|
+
cnt += 1
|
54
|
+
end
|
55
|
+
exit 0
|
232
56
|
end
|
233
57
|
|
234
58
|
def parse_options
|
235
59
|
@fg = nil
|
236
60
|
@bg = nil
|
237
61
|
@tx = nil
|
238
|
-
@pickups
|
239
|
-
@is_watch
|
240
|
-
@last_lb
|
62
|
+
@pickups = []
|
63
|
+
@is_watch = false
|
64
|
+
@last_lb = true
|
65
|
+
@is_stripe = false
|
241
66
|
|
242
67
|
require "optparse"
|
243
68
|
opt = OptionParser.new
|
244
69
|
|
245
70
|
opt.on("-h") { usage }
|
246
71
|
opt.on("-v") { version }
|
247
|
-
opt.on("-s", "--
|
248
|
-
opt.on("-l", "--
|
72
|
+
opt.on("-s", "--symbol-list") { display_symbol_list }
|
73
|
+
opt.on("-l", "--index-list") { display_color_index }
|
74
|
+
opt.on("--symbol_list") { display_symbol_list } # for compatibility
|
75
|
+
opt.on("--index_list") { display_color_index } # for compatibility
|
249
76
|
opt.on("--fg val", "-f val") { |val| @fg = val }
|
250
77
|
opt.on("--bg val", "-b val") { |val| @bg = val }
|
251
78
|
opt.on("--tx val", "-t val") { |val| @tx = val }
|
252
79
|
opt.on("--pickup val", "-p val") { |val| @pickups << val }
|
253
|
-
opt.on("-w", "--watch") { @is_watch
|
254
|
-
opt.on("-n") { @last_lb
|
80
|
+
opt.on("-w", "--watch") { @is_watch = true }
|
81
|
+
opt.on("-n") { @last_lb = false }
|
82
|
+
opt.on("--stripe") { @is_stripe = true }
|
255
83
|
|
256
84
|
begin
|
257
85
|
opt.parse!(ARGV)
|
@@ -273,6 +101,12 @@ def parse_options
|
|
273
101
|
@tx = res
|
274
102
|
end
|
275
103
|
|
104
|
+
# ignore --pickup option when specified --stripe option
|
105
|
+
if @pickups.size > 0 && @is_stripe
|
106
|
+
warn "pickup option is ignored because your specified --stripe option."
|
107
|
+
@pickups = []
|
108
|
+
end
|
109
|
+
|
276
110
|
# parse pickups
|
277
111
|
if @pickups.size > 0
|
278
112
|
code_pickup = ""
|
@@ -298,10 +132,18 @@ parse_options
|
|
298
132
|
require_color_echo_get
|
299
133
|
if @is_watch
|
300
134
|
# Interactive mode
|
135
|
+
@exit_words = ["quit", "exit", "bye"]
|
301
136
|
output_interactive
|
302
137
|
else
|
303
138
|
if has_stdin
|
304
139
|
target = STDIN.read
|
140
|
+
|
141
|
+
if ARGV.size > 0
|
142
|
+
print target
|
143
|
+
argv = ARGV.join(" ")
|
144
|
+
argv += $/ if @last_lb
|
145
|
+
output(argv)
|
146
|
+
end
|
305
147
|
else
|
306
148
|
target = ARGV.join(" ")
|
307
149
|
target += $/ if @last_lb
|
data/bin/lib/display.rb
ADDED
@@ -0,0 +1,212 @@
|
|
1
|
+
def version
|
2
|
+
require_color_echo
|
3
|
+
|
4
|
+
puts CE::VERSION
|
5
|
+
exit 0
|
6
|
+
end
|
7
|
+
|
8
|
+
def usage
|
9
|
+
require_color_echo
|
10
|
+
|
11
|
+
CE.once.ch :yellow
|
12
|
+
puts <<-EOS
|
13
|
+
|
14
|
+
#{CE::LIBS_NAME} - #{CE::SUMMARY}
|
15
|
+
VERSION: #{CE::VERSION}
|
16
|
+
README: #{CE::DOCS_PAGE}
|
17
|
+
|
18
|
+
EOS
|
19
|
+
|
20
|
+
padding = " " * 4
|
21
|
+
headers = ["* Usage", "* Options", "* Example"]
|
22
|
+
headers_op = [
|
23
|
+
"-v:", "--symbol-list:", "--index-list:", "--pickup word [--pickup word ...]:", "--fg color_name:", "--bg color_name:",
|
24
|
+
"--tx text_attribute[,...]:", "--watch:", "--stripe:", "-n:", "-h:"
|
25
|
+
]
|
26
|
+
CE.pickup(headers, :h_green)
|
27
|
+
CE.pickup(headers_op, :cyan)
|
28
|
+
|
29
|
+
puts padding + "* Usage"
|
30
|
+
|
31
|
+
CE.ch :h_blue
|
32
|
+
puts padding * 2 + "color_echo [options] text"
|
33
|
+
puts padding * 2 + "color_echo [options] < /path/to/file"
|
34
|
+
puts padding * 2 + "echo text | color_echo [options]"
|
35
|
+
puts padding * 2 + "color_echo -v"
|
36
|
+
puts padding * 2 + "color_echo -s"
|
37
|
+
puts padding * 2 + "color_echo -l"
|
38
|
+
puts padding * 2 + "color_echo -h" + $/ + $/
|
39
|
+
CE.off :fg
|
40
|
+
|
41
|
+
puts padding + "* Options"
|
42
|
+
|
43
|
+
puts padding * 2 + "-v:"
|
44
|
+
puts padding * 3 + "Display version of color_echo." + $/ + $/
|
45
|
+
|
46
|
+
puts padding * 2 + "--symbol-list:"
|
47
|
+
puts padding * 3 + "Display symbol list that can to specify."
|
48
|
+
puts padding * 3 + "short option is -s." + $/ + $/
|
49
|
+
|
50
|
+
puts padding * 2 + "--index-list:"
|
51
|
+
puts padding * 3 + "Display color index list that can to specify."
|
52
|
+
puts padding * 3 + "short option is -l." + $/ + $/
|
53
|
+
|
54
|
+
puts padding * 2 + "--pickup word [--pickup word ...]:"
|
55
|
+
puts padding * 3 + "Decorate your specified wrods. You can use this option any number of times."
|
56
|
+
puts padding * 3 + "Regular expressions can be used; like that -> /^foo/i"
|
57
|
+
puts padding * 3 + "short option is -p." + $/ + $/
|
58
|
+
|
59
|
+
puts padding * 2 + "--fg color_name:"
|
60
|
+
puts padding * 3 + "Decorate the foreground color."
|
61
|
+
puts padding * 3 + "short option is -f." + $/ + $/
|
62
|
+
|
63
|
+
puts padding * 2 + "--bg color_name:"
|
64
|
+
puts padding * 3 + "Decorate the background color."
|
65
|
+
puts padding * 3 + "short option is -b." + $/ + $/
|
66
|
+
|
67
|
+
puts padding * 2 + "--tx text_attribute[,...]:"
|
68
|
+
puts padding * 3 + "Decorate the text attribute."
|
69
|
+
puts padding * 3 + "short option is -t." + $/ + $/
|
70
|
+
|
71
|
+
puts padding * 2 + "--watch:"
|
72
|
+
puts padding * 3 + "Interactive mode. Break word is -> exit, quit, bye; Or Ctl + c"
|
73
|
+
puts padding * 3 + "short option is -w." + $/ + $/
|
74
|
+
|
75
|
+
puts padding * 2 + "--stripe:"
|
76
|
+
puts padding * 3 + "Apply the decoration for each row."
|
77
|
+
puts padding * 3 + "pickup option is ignored." + $/ + $/
|
78
|
+
|
79
|
+
puts padding * 2 + "-n:"
|
80
|
+
puts padding * 3 + "Do not output the trailing newline." + $/ + $/
|
81
|
+
|
82
|
+
puts padding * 2 + "-h:"
|
83
|
+
puts padding * 3 + "Show this message." + $/ + $/
|
84
|
+
|
85
|
+
puts padding + "* Example"
|
86
|
+
|
87
|
+
CE.once.ch :h_magenta
|
88
|
+
puts padding * 2 + %(* color_echo can to highlight even when you following the log file by tailf, tail -f.)
|
89
|
+
puts padding * 3 + %(tailf /var/log/httpd/access_log | color_echo -w -p "127.0.0.1" -t bold)
|
90
|
+
puts padding * 3 + %(tailf /var/log/php/php_error.log | color_echo -w -p "foo.php" -p "Fatal error:" -f h_blue) + $/ + $/
|
91
|
+
|
92
|
+
CE.once.ch :h_magenta
|
93
|
+
puts padding * 2 + %(* color_echo is useful to read the access log, etc.)
|
94
|
+
puts padding * 3 + %(cat /var/log/httpd/access_log | color_echo -p "Sun Jan 18" -f h_cyan -t underscore | less)
|
95
|
+
puts padding * 3 + %(color_echo -p "Sun Jan 18" -f h_cyan -t underscore < /var/log/httpd/access_log | less)
|
96
|
+
puts padding * 3 + %((color_echo -f cyan -p /\\\\s2..\\\\s/ | color_echo -f h_red -p /\\\\s5..\\\\s/ | less) < /var/log/httpd/access_log)
|
97
|
+
puts padding * 3 + %(sed -n 1,1000p /var/log/httpd/access_log | color_echo -f cyan -p /\\\\s2..\\\\s/ | color_echo -f h_red -p /\\\\s5..\\\\s/ | less) + $/ + $/
|
98
|
+
|
99
|
+
CE.once.ch :h_magenta
|
100
|
+
puts padding * 2 + %(* It is a simple to use.)
|
101
|
+
puts padding * 3 + %(color_echo Hello\\!\\! -f h_white -b index199)
|
102
|
+
puts padding * 3 + %(color_echo Hello\\!\\! -t blink,bold -f magenta) + $/ + $/
|
103
|
+
|
104
|
+
CE.once.ch :h_magenta
|
105
|
+
puts padding * 2 + %(* color_echo can to receive the standard input.)
|
106
|
+
puts padding * 3 + %(echo FooFoOfOO | color_echo -t reverse_video)
|
107
|
+
puts padding * 3 + %(echo FooFoOfOO | color_echo -f index130 -p /foo$/i | color_echo -f index180 -p /^foo/i)
|
108
|
+
puts padding * 3 + %(netstat -na | color_echo -p ":80" | color_echo -p "127.0.0.1" -f h_cyan) + $/ + $/
|
109
|
+
|
110
|
+
CE.once.ch :h_magenta
|
111
|
+
puts padding * 2 + %(* color_echo can to decorate for each row.)
|
112
|
+
puts padding * 3 + %(color_echo -f gray -t bold --stripe < /path/to/file)
|
113
|
+
puts padding * 3 + %(tailf /var/log/httpd/access_log | color_echo -w -f black -b index150 -t bold --stripe) + $/ + $/
|
114
|
+
|
115
|
+
exit 0
|
116
|
+
end
|
117
|
+
|
118
|
+
def display_color_index
|
119
|
+
require_color_echo
|
120
|
+
|
121
|
+
CE.rainbow
|
122
|
+
cnt = 134
|
123
|
+
padding = " " * 2
|
124
|
+
mes = "OK, Let me check color index list... :)"
|
125
|
+
puts padding + "-" * cnt
|
126
|
+
puts padding + " " * ((cnt - mes.size)/2) + mes
|
127
|
+
puts padding + "-" * cnt
|
128
|
+
|
129
|
+
print padding
|
130
|
+
256.times do |i|
|
131
|
+
num = i + 1
|
132
|
+
CE.fg "index#{num}".intern
|
133
|
+
print "index#{num}" + " " * (4 - num.to_s.size)
|
134
|
+
CE.bg "index#{num}".intern
|
135
|
+
print " " * 5
|
136
|
+
CE.off
|
137
|
+
print " " * 3
|
138
|
+
|
139
|
+
if num % 8 == 0
|
140
|
+
print $/ + $/
|
141
|
+
print padding if num != 256
|
142
|
+
end
|
143
|
+
end
|
144
|
+
CE.off
|
145
|
+
|
146
|
+
exit 0
|
147
|
+
end
|
148
|
+
|
149
|
+
def display_symbol_list
|
150
|
+
require_color_echo
|
151
|
+
|
152
|
+
symbols_color = [
|
153
|
+
:black,
|
154
|
+
:gray,
|
155
|
+
:red,
|
156
|
+
:h_red,
|
157
|
+
:green,
|
158
|
+
:h_green,
|
159
|
+
:yellow,
|
160
|
+
:h_yellow,
|
161
|
+
:blue,
|
162
|
+
:h_blue,
|
163
|
+
:magenta,
|
164
|
+
:h_magenta,
|
165
|
+
:cyan,
|
166
|
+
:h_cyan,
|
167
|
+
:white,
|
168
|
+
:h_white
|
169
|
+
]
|
170
|
+
symbols_text_attr = [
|
171
|
+
:bold,
|
172
|
+
:underscore,
|
173
|
+
:blink,
|
174
|
+
:reverse_video,
|
175
|
+
:concealed
|
176
|
+
]
|
177
|
+
|
178
|
+
CE.times(3).rainbow
|
179
|
+
cnt = 60
|
180
|
+
padding = " " * 2
|
181
|
+
mes = "OK, Let me check color name list... :)"
|
182
|
+
puts padding + "-" * cnt
|
183
|
+
puts padding + " " * ((cnt - mes.size)/2) + mes
|
184
|
+
puts padding + "-" * cnt
|
185
|
+
|
186
|
+
header_colors = "* foreground or background colors"
|
187
|
+
header_text_attrs = "* text attributes"
|
188
|
+
CE.pickup([header_colors, header_text_attrs], :cyan, nil, [:underscore, :bold])
|
189
|
+
|
190
|
+
puts padding + header_colors
|
191
|
+
symbols_color.each do |color_name|
|
192
|
+
CE.off(:bg).fg color_name
|
193
|
+
print "#{padding*2}:#{color_name}" + " " * (11 - color_name.to_s.size)
|
194
|
+
CE.bg color_name
|
195
|
+
puts color_name.to_s + " " * (30 - color_name.to_s.size)
|
196
|
+
end
|
197
|
+
|
198
|
+
CE.off [:bg, :fg]
|
199
|
+
print $/ + $/
|
200
|
+
|
201
|
+
puts padding + header_text_attrs
|
202
|
+
symbols_text_attr.each do |tx_name|
|
203
|
+
CE.off(:tx)
|
204
|
+
CE.tx tx_name if tx_name != :concealed
|
205
|
+
puts "#{padding*2}:#{tx_name}" + " " * (30 - tx_name.to_s.size)
|
206
|
+
end
|
207
|
+
|
208
|
+
print $/
|
209
|
+
|
210
|
+
exit 0
|
211
|
+
end
|
212
|
+
|
data/lib/color_echo/const.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: color_echo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khotta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Decorate the command line output with ANSI escape sequence.
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- LICENSE.txt
|
24
24
|
- README.md
|
25
25
|
- bin/color_echo
|
26
|
+
- bin/lib/display.rb
|
26
27
|
- lib/color_echo.rb
|
27
28
|
- lib/color_echo/const.rb
|
28
29
|
- lib/color_echo/functions.rb
|