게시물 1,376건
   
Colout - Color Up Arbitrary Command Output
글쓴이 : 최고관리자 날짜 : 2016-08-16 (화) 18:11 조회 : 5178
글주소 :
                                
테스트 환경
 OS : Ubuntu 14.04 LTS

colout - 터미널 텍스트에 색깔을 입히는 명렁어
install
# apt-get install python-setuptools
# easy_install colout


example
<text stream> | colout <pattern to color> [color [style]]

# tail -n 10 /var/log/boot.log |colout OK
OK 단어가 포함된것만 붉은색(기본)으로 표시


# tail -n 10 /var/log/boot.log |colout OK yellow bold
OK 단어가 포함된것만 노란색으로 표시


#  tail -n 10 /var/log/boot.log |colout  "^.*OK.*$" red bold


Color maps
# tail /var/log/boot.log |colout "^.*$" rainbow


-c 옵션을 사용해서 라인마다 색상 지정
# tail /var/log/boot.log | colout -c "^.*$" blue,yellow,white normal


각 라인마다 랜덤한 색상으로 표시
# tail /var/log/boot.log | colout "^.*$" random


Source Code 강조
colout -s [PATTERN] [COLOR]
# tail -n 20 /etc/openstack-dashboard/local_settings.py | grep -v "^\s*$" | colout -s Python monokai



# colout  --help
usage: colout.py [-h] [-g] [-c] [-l SCALE] [-a] [-t] [-T DIR] [-P DIR] [-r]
                 [--debug] [-s]
                 REGEX [COLOR] [STYLE]

A regular expression based formatter that color up an arbitrary text stream.

positional arguments:
  REGEX                 A regular expression
  COLOR                 A number in [0…255], a color name, a colormap name,
                        a palette or a comma-separated list of those values.
  STYLE                 One of the available styles or a comma-separated list
                        of styles.

optional arguments:
  -h, --help            show this help message and exit
  -g, --groups          For color maps (random, rainbow), iterate over
                        matching groups in the pattern instead of over
                        patterns
  -c, --colormap        Use the given colors as a colormap (cycle the colors
                        at each match)
  -l SCALE, --scale SCALE
                        When using the 'scale' colormap, parse matches as
                        decimal numbers (taking your locale into account) and
                        apply the rainbow colormap linearly between the given
                        SCALE=min,max
  -a, --all             Color the whole input at once instead of line per line
                        (really useful for coloring a source code file with
                        strings on multiple lines).
  -t, --theme           Interpret REGEX as a theme.
  -T DIR, --themes-dir DIR
                        Search for additional themes (colout_*.py files) in
                        this directory
  -P DIR, --palettes-dir DIR
                        Search for additional palettes (*.gpl files) in this
                        directory
  -r, --resources       Print the names of all available colors, styles,
                        themes and palettes.
  --debug               Debug mode: print what's going on internally, useful
                        if you want to check what features are available.
  -s, --source          Interpret REGEX as a source code readable by the
                        Pygments library. If the first letter of PATTERN is
                        upper case, use the 256 colors mode, if it is lower
                        case, use the 8 colors mode. Interpret COLOR as a
                        Pygments style.

좀더 다양한 예제는 아래 링크참고
참고  http://nojhan.github.io/colout/
        https://github.com/nojhan/colout


이름 패스워드
비밀글 (체크하면 글쓴이만 내용을 확인할 수 있습니다.)
왼쪽의 글자를 입력하세요.
   

 



 
사이트명 : 모지리네 | 대표 : 이경현 | 개인커뮤니티 : 랭키닷컴 운영체제(OS) | 경기도 성남시 분당구 | 전자우편 : mojily골뱅이chonnom.com Copyright ⓒ www.chonnom.com www.kyunghyun.net www.mojily.net. All rights reserved.