├── .grcat ├── .my.cnf ├── LICENSE ├── README.md ├── Screen_G.png └── Screen_table.png /.grcat: -------------------------------------------------------------------------------- 1 | #default word color 2 | #regexp=[\w.,\:\-_/]+ 3 | regexp=.+ 4 | colours=green 5 | - 6 | 7 | #table borders 8 | regexp=[+\-]+[+\-]|[|] 9 | colours=red 10 | - 11 | 12 | #data in ( ) and ' ' 13 | regexp=\([\w\d,']+\) 14 | colours=white 15 | - 16 | 17 | #numeric 18 | regexp=\s[\d\.]+\s*($|(?=\|)) 19 | colours=yellow 20 | - 21 | 22 | #date 23 | regexp=\d{4}-\d{2}-\d{2} 24 | colours=cyan 25 | - 26 | #time 27 | regexp=\d{2}:\d{2}:\d{2} 28 | colours=cyan 29 | - 30 | 31 | #IP 32 | regexp=(\d{1,3}\.){3}\d{1,3}(:\d{1,5})? 33 | colours=cyan 34 | - 35 | 36 | #schema 37 | regexp=`\w+` 38 | colours=yellow 39 | - 40 | 41 | #email 42 | regexp=[\w\.\-_]+@[\w\.\-_]+ 43 | colours=magenta 44 | - 45 | 46 | #row delimeter when using \G key 47 | regexp=[*]+.+[*]+ 48 | count=stop 49 | colours=white 50 | - 51 | 52 | #column names when using \G key 53 | regexp=^\s*\w+: 54 | colours=white 55 | -------------------------------------------------------------------------------- /.my.cnf: -------------------------------------------------------------------------------- 1 | [mysql] 2 | pager = grcat ~/.grcat -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Nitso [https://github.com/nitso] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | colour-mysql-console 2 | ==================== 3 | Sample config files showing how to colorize linux console mysql client using grc 4 | 5 | How to use it 6 | ------------- 7 | 1. Install grc (for debian systems: `apt-get install grc`) 8 | 2. Copy both config files into your home directory: [.grcat](./.grcat) and [.my.cnf](./.my.cnf) 9 | 3. Run mysql client `mysql -u -p -h ` 10 | 4. Enjoy! 11 | 12 | How does it work 13 | ---------------- 14 | Mysql client supports using predefined pager for data output. 15 | So we can set grcat (Generic Colouriser) for processing mysql output. 16 | grcat reads supplied config file, parses output according to regexp's and adds colours. 17 | grc manual can be founded via `man grc` or here: http://kassiopeia.juls.savba.sk/~garabik/software/grc/README.txt 18 | 19 | Sample screenshots 20 | ------------------ 21 | 22 | ![Table screenshot](https://raw.github.com/nitso/colour-mysql-console/master/Screen_table.png) 23 | ![Vertical screenshot](https://raw.github.com/nitso/colour-mysql-console/master/Screen_G.png) 24 | 25 | Another one nice hack 26 | --------------------- 27 | You can also use `less` in pager to have some features like scrolling, search, line numbers etc. 28 | `pager = grcat ~/.grcat | less -RSFXin` 29 | 30 | Just type `man less` to read about less parameters. 31 | 32 | LICENSE 33 | ------- 34 | Project distributes with standard MIT license 35 | -------------------------------------------------------------------------------- /Screen_G.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nitso/colour-mysql-console/2f62b8a9b18b22fdc2ccfa0df2d92e0ca1275e74/Screen_G.png -------------------------------------------------------------------------------- /Screen_table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nitso/colour-mysql-console/2f62b8a9b18b22fdc2ccfa0df2d92e0ca1275e74/Screen_table.png --------------------------------------------------------------------------------