bat
A cat clone with syntax highlighting and Git integration (https://github.com/sharkdp/bat)
--- Viewing Files ---
To display a file with syntax highlighting:
To display multiple files
To display a file with line numbers (default)
To display a file without line numbers
To display a file without any decorations (plain output)
To show non-printable characters
To show only a specific line range
bat -r <start>:<end> <file>
--- Syntax & Themes ---
To list all supported syntax languages:
To set the syntax language explicitly
bat --language <language> <file>
To list all available color themes
To display a file using a specific theme
bat --theme <theme_name> <file>
To preview all themes on a file
bat --list-themes | xargs -I{} sh -c 'echo "Theme: {}"; bat --theme={} <file>'
--- Paging & Integration ---
To disable the pager:
To use bat as a colorizing pager for man pages (add to .bashrc)
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
To use bat with tail -f for live log viewing
tail -f <logfile> | bat --paging=never -l log
To use bat as a drop-in cat replacement (add to .bashrc)
--- Reading from Stdin ---
To pipe input to bat with explicit language:
<command> | bat --language <language>
To show git diff output with syntax highlighting
git diff | bat --language diff