{"name":"Colout","tagline":"Color Up Arbitrary Command Ouput","body":"\r\n# colout\r\n\r\n## Introduction\r\n\r\ncolout is a simple command to add colors to a text stream in your terminal.\r\n\r\nThe `colout` command line interface has been carefully designed to be simple. Basically, you will call it like: `<text\r\nstream> | colout <pattern to color> [color [style]]`.\r\n\r\ncolout has the ability to use 8 colors mode, 256 colors mode, colormaps, themes and source code syntax coloring.\r\nPatterns are regular expressions.\r\n\r\nYou can think of colout as an alternative to `grep --color` which will preserve the surrounding context, whith more\r\npowerful coloring capabilites.\r\n\r\n\r\n## Useful examples\r\n\r\n### Basic coloring\r\n\r\nIn the most simple use, you just have to call `colout word` to highlight what you want to spot in a text stream. This is\r\nparticularly useful when examining logs.\r\n\r\nColor every occurence of the word \"fail\" in bold red, in the boot log:\r\n`tail /var/log/boot.log | colout fail`\r\n\r\n![](boot_log_fail_red_bold.png)\r\n\r\nUsing regular expressions, you can highlight anything you want in a text stream.\r\n\r\nColor every _line_ containing the word \"fail\" in bold red, in the boot log:\r\n`tail /var/log/boot.log | colout \"^.*fail.*$\" red bold`\r\n\r\n![](boot_log_fail_line_red_bold.png)\r\n\r\nColor in blue the user name of the `ps` output that have been greped:\r\n`ps aux | grep firefox | colout \"^\\w+\\s\" blue`\r\n\r\n![](ps_grep_firefox_user_blue.png)\r\n\r\n\r\n### Multiple colors\r\n\r\nUsing groups in the regular expressions, you can highlight several matchs in different colors.\r\n\r\nHighlight the different parts of the permissions of files in your home directories, that are `rwx` for user and group,\r\nbut `r-x` for others:\r\n`ls -l ~ | colout \"^(d*)-*(rwx)(rwx)(r-x)\" blue,red,yellow,green`\r\n\r\n![](ll_perms_groups_4_colors.png)\r\n\r\nUsing colormaps, you can change the colors for each lines, this is particularly useful for reading logs that have long\r\nlines that are wrapped.\r\n`tail /var/log/kern.log | colout \"^.*$\" rainbow`\r\n\r\n![](kern_log_rainbow.png)\r\n\r\nIf you want more colors, you can highlight each line of your log with a random one among the 256 ANSI colors:\r\n`tail /var/log/dmesg | colout \"^.*$\" Random`\r\n\r\n![](dmesg_Random.png)\r\n\r\nYou can even fill your screen with esoteric disco characters (not _that_ useful, but fun):\r\n`cat /dev/urandom | colout \".\" Random`\r\n\r\n![](urandom_character.png)\r\n\r\n\r\n### Source code\r\n\r\nYou can use colout as a basic proxy to the pygments library, if you want to highlight a source code.\r\n\r\nFor example, let say you want to have a quick look at a source file, without being bothered by comments and empty lines:\r\n`tail colout.py | grep -v \"#\" | grep -v \"^\\s*$\" | colout -s Python monokai`\r\n\r\n![](code_grep_monokai.png)\r\n\r\nBut even more interesting, you can highlight the syntax of the matching parts of your text stream, which is useful\r\nfor spotting code in a log.\r\n\r\nFor example, color the code parts in the output of `g++` (they come inside single quotes):\r\n`make 2>&1 | colout \"'.*'\" Cpp vim`\r\n\r\n![](make_Cpp_vim.png)\r\n\r\n\r\n### Themes\r\n\r\ncolout comes with a set of handy shortcuts for coloring common outputs.\r\n\r\nFor example, if you often build your software with `cmake` but find its coloring scheme a bit boring, you can use the\r\nfollowing shortcut:\r\n`make 2>&1 | colout -t cmake`\r\n\r\n![](cmake_theme_paradiseo.png)\r\n\r\nYou can, of course, combine several calls to colout using pipes:\r\n`make 2>&1 | colout -t cmake | colout -t g++`\r\n\r\n![](themes_cmake_g++_paradiseo.png)\r\n\r\n\r\n## Tips\r\n\r\nTo be able to use the syntax highlighting, you should install the `python-pygments` library.\r\n\r\n`colout -h` will give you the lists of available colors, themes and programming languages.\r\n\r\nColormaps and source code syntax highlighting most often comes in 8 or 256 colors mode. Use a lower case first letter\r\nfor the 8 colors mode and an upper case first one for the 256 colors.\r\n\r\nThe 8 colors mode syntax highlighting only comes in two styles: light and dark. If you want more fancy styles, you\r\nshould use 256 colors mode, and thus upper case the first letter of the language name, or else the style is ignored.\r\n\r\nYou can leave simple words without quotes, but it is better to put the regexp in quotes to avoid escaping special\r\ncharacters that would overwise be interpreted\r\nby your shell (like parenthesis).\r\n\r\nDo not hesitate to design your own theme, they are defined as separated files, and basically are just like chaining\r\nseveral calls to colout in pipes, with the possibility to use python code around.\r\n\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}