Skip to Content
CLIChat & Skillscmdop highlight & cat

Print files with syntax highlighting

Two commands print files with colour: cmdop highlight, which is always a highlighter, and cmdop cat, which is a drop-in replacement for cat.

cmdop highlight

cmdop highlight main.py cmdop highlight -n config.yaml cmdop highlight -l python script cmdop highlight -t dracula main.go cmdop highlight *.go
FlagPurpose
-n, --line-numbersShow line numbers.
-l, --language <lang>Force a language instead of detecting it from the extension.
-t, --theme <theme>Colour theme. Default monokai.
--list-languagesList supported languages.
--list-themesList available themes.

cmdop cat

cmdop cat prints files like cat(1) and adds highlighting only when the output is a terminal. It is a genuine drop-in in two ways:

  • Piped or redirected output is the raw bytes — no colour, no decoration — so cmdop cat main.go | grep func behaves exactly like cat.
  • Any real cat(1) flag it cannot render itself (-b, -e, -n, -s, -t, -u, -v, -A, and the GNU long forms) is handed to the system cat unchanged, so you get your platform’s authentic behavior and its authentic error messages.
cmdop cat main.go # highlighted in a terminal cmdop cat a.py b.py # multiple files, each with a header cmdop cat --number config.yaml # line numbers on the highlighted output cmdop cat -n config.yaml # POSIX -n -> the system cat cmdop cat --language json data cmdop cat --color=always f | less -R # force colour through a pipe

With no file arguments, or with -, it reads standard input.

FlagPurpose
--color auto|always|neverWhen to colorize. Default auto.
-p, --plainNever colorize. Same as --color=never.
--numberLine numbers on the highlighted output. Note POSIX -n goes to the system cat instead.
--language <lang>Force a language. Note POSIX -l goes to the system cat.
--theme <theme>Colour theme. Default monokai.
--install-aliasPrint the shell alias cat='cmdop cat'; add --apply to append it to your shell rc file.

To make it your cat:

cmdop cat --install-alias --apply
Last updated on