highlight

Print the content of FILE with syntax highlighting.

With no FILE, or when FILE is -, read standard input.

highlight [OPTIONS] [FILE]

Options

-m, --mime <mime>

The MIME time to use for highlighting.

-l, --lexer <lexer>

The Pygments lexer to use for highlighting.

-T, --show-tabs

Display TAB characters as ^I.

-E, --show-ends

Display $ at the end of each line.

-n, --number

Number all output lines.

-D, --debug

Print the lexer name to stderr.

--version

Show the version and exit.

Arguments

FILE

Optional argument. Default None

Notes

  • --lexer and --mime are mutually exclusive.

  • If no --lexer or --mime option is given, the lexer is determined from FILE. If reading from standard input, of if the file extension is unknown, the lexer is determined by examining the file’s contents.

  • If the --mime option is given but no lexer can be found for that mime type the mime type is ignored.

  • See https://pygments.org/docs/lexers/ for a list of available lexers.

Examples

Highlight a Python source code file.

highlight code.py

Highlight a Ruby source code file with the RubyConsoleLexer.

highlight code.rb --lexer rbcon

Highlight a Rust source code file with line numbers.

highlight main.rs --number