地方エンジニアの学習日記

興味ある技術の雑なメモだったりを書いてくブログ。たまに日記とガジェット紹介。

【CLI】jqでlessして色をつけたい

lessに-Rをつけて

       -R or --RAW-CONTROL-CHARS
              Like -r, but only ANSI "color" escape sequences and OSC 8 hyperlink sequences are output in "raw" form.  Unlike -r, the screen appearance is
              maintained correctly, provided that there are no escape sequences in the file other than these types of escape sequences.  Color escape sequences are
              only supported when the color is changed within one line, not across lines.  In other words, the beginning of each line is assumed to be normal (non-
              colored), regardless of any escape sequences in previous lines.  For the purpose of keeping track of screen appearance, these escape sequences are
              assumed to not move the cursor.

jqには-Cをつければ良い

-C               colorize JSON;

LESSという環境変数にオプションを入れておけばlessの方は反映されるのでやっておくだけでも良い

$ export LESS='-R'