scale example + code on separate line

This commit is contained in:
Johann Dreo 2013-04-03 19:24:18 +02:00
commit 471e90f888
2 changed files with 26 additions and 21 deletions

BIN
cmake_scale.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View file

@ -45,7 +45,7 @@
<p>colout is a simple command to add colors to a text stream in your terminal.</p>
<p>The <code>colout</code> command line interface has been carefully designed to be simple. Basically, you will call it like: <code>&lt;text
stream&gt; | colout &lt;pattern to color&gt; [color [style]]</code>.</p>
stream&gt; | colout &lt;pattern to color&gt; [color [style]]</code></p>
<p>colout has the ability to use 8 colors mode, 256 colors mode, colormaps, themes and source code syntax coloring.
Patterns are regular expressions.</p>
@ -60,20 +60,20 @@ powerful coloring capabilites.</p>
<p>In the most simple use, you just have to call <code>colout word</code> to highlight what you want to spot in a text stream. This is
particularly useful when examining logs.</p>
<p>Color every occurence of the word "fail" in bold red, in the boot log:
<code>tail /var/log/boot.log | colout fail</code></p>
<p>Color every occurence of the word "fail" in bold red, in the boot log:</p>
<p><code>tail /var/log/boot.log | colout fail</code></p>
<p><img src="boot_log_fail_red_bold.png" alt=""></p>
<p>Using regular expressions, you can highlight anything you want in a text stream.</p>
<p>Color every <em>line</em> containing the word "fail" in bold red, in the boot log:
<code>tail /var/log/boot.log | colout "^.*fail.*$" red bold</code></p>
<p>Color every <em>line</em> containing the word "fail" in bold red, in the boot log:</p>
<p><code>tail /var/log/boot.log | colout "^.*fail.*$" red bold</code></p>
<p><img src="boot_log_fail_line_red_bold.png" alt=""></p>
<p>Color in blue the user name of the <code>ps</code> output that have been greped:
<code>ps aux | grep firefox | colout "^\w+\s" blue</code></p>
<p>Color in blue the user name of the <code>ps</code> output that have been greped:</p>
<p><code>ps aux | grep firefox | colout "^\w+\s" blue</code></p>
<p><img src="ps_grep_firefox_user_blue.png" alt=""></p>
@ -82,24 +82,29 @@ particularly useful when examining logs.</p>
<p>Using groups in the regular expressions, you can highlight several matchs in different colors.</p>
<p>Highlight the different parts of the permissions of files in your home directories, that are <code>rwx</code> for user and group,
but <code>r-x</code> for others:
<code>ls -l ~ | colout "^(d*)-*(rwx)(rwx)(r-x)" blue,red,yellow,green</code></p>
but <code>r-x</code> for others:</p>
<p><code>ls -l ~ | colout "^(d*)-*(rwx)(rwx)(r-x)" blue,red,yellow,green</code></p>
<p><img src="ll_perms_groups_4_colors.png" alt=""></p>
<p>Using colormaps, you can change the colors for each lines, this is particularly useful for reading logs that have long
lines that are wrapped.
<code>tail /var/log/kern.log | colout "^.*$" rainbow</code></p>
<p><code>tail /var/log/kern.log | colout "^.*$" rainbow</code></p>
<p><img src="kern_log_rainbow.png" alt=""></p>
<p>If you want more colors, you can highlight each line of your log with a random one among the 256 ANSI colors:
<code>tail /var/log/dmesg | colout "^.*$" Random</code></p>
<p>If you want more colors, you can highlight each line of your log with a random one among the 256 ANSI colors:</p>
<p><code>tail /var/log/dmesg | colout "^.*$" Random</code></p>
<p><img src="dmesg_Random.png" alt=""></p>
<p>You can even fill your screen with esoteric disco characters (not <em>that</em> useful, but fun):
<code>cat /dev/urandom | colout "." Random</code></p>
<p>You can color numbers according to their value on a linear scale:</p>
<p><code>cmake .. &amp;&amp; make 2&gt;&amp;1 | colout --scale 0,100 "\[(.*)%\]" scale</code></p>
<p><img src="cmake_scale.png" alt=""></p>
<p>You can even fill your screen with esoteric disco characters (not <em>that</em> useful, but fun):</p>
<p><code>cat /dev/urandom | colout "." Random</code></p>
<p><img src="urandom_character.png" alt=""></p>
@ -107,16 +112,16 @@ lines that are wrapped.
<p>You can use colout as a basic proxy to the pygments library, if you want to highlight a source code.</p>
<p>For example, let say you want to have a quick look at a source file, without being bothered by comments and empty lines:
<code>tail colout.py | grep -v "#" | grep -v "^\s*$" | colout -s Python monokai</code></p>
<p>For example, let say you want to have a quick look at a source file, without being bothered by comments and empty lines:</p>
<p><code>tail colout.py | grep -v "#" | grep -v "^\s*$" | colout -s Python monokai</code></p>
<p><img src="code_grep_monokai.png" alt=""></p>
<p>But even more interesting, you can highlight the syntax of the matching parts of your text stream, which is useful
for spotting code in a log.</p>
<p>For example, color the code parts in the output of <code>g++</code> (they come inside single quotes):
<code>make 2&gt;&amp;1 | colout "'.*'" Cpp vim</code></p>
<p>For example, color the code parts in the output of <code>g++</code> (they come inside single quotes):</p>
<p><code>make 2&gt;&amp;1 | colout "'.*'" Cpp vim</code></p>
<p><img src="make_Cpp_vim.png" alt=""></p>
@ -126,12 +131,12 @@ for spotting code in a log.</p>
<p>For example, if you often build your software with <code>cmake</code> but find its coloring scheme a bit boring, you can use the
following shortcut:
<code>make 2&gt;&amp;1 | colout -t cmake</code></p>
<p><code>make 2&gt;&amp;1 | colout -t cmake</code></p>
<p><img src="cmake_theme_paradiseo.png" alt=""></p>
<p>You can, of course, combine several calls to colout using pipes:
<code>make 2&gt;&amp;1 | colout -t cmake | colout -t g++</code></p>
<p><code>make 2&gt;&amp;1 | colout -t cmake | colout -t g++</code></p>
<p><img src="themes_cmake_g++_paradiseo.png" alt=""></p>
@ -159,4 +164,4 @@ several calls to colout in pipes, with the possibility to use python code around
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
</body>
</html>
</html>