81 votes
Accepted

Syntax highlighting in the terminal

With highlight on a terminal that supports the same colour escape sequences as xterm: highlight -O xterm256 your-file | less -R With ruby-rouge: rougify your-file | less -R With python-pygments: ...
Stéphane Chazelas's user avatar
31 votes
Accepted

vim: Force specific syntax via command-line argument

You can use: vim -c 'set syntax=sql' -
Lambert's user avatar
  • 12.7k
19 votes
Accepted

How to enable syntax highlighting in ranger preview?

$ sudo apt install highlight then reopen ranger.
thiagowfx's user avatar
  • 1,249
14 votes

Syntax highlighting in the terminal

I use GNU source-highlight combined with less -R for this. Add the following lines to your shell's initialization file (~/.bashrc, for example): cless(){ LESSOPEN='| source-highlight --failsafe --...
terdon's user avatar
  • 242k
11 votes

How to enable syntax highlighting in ranger preview?

Ranger supports highlight, see https://gitlab.com/saalen/highlight for details Install on macOS by running brew install highlight. The list of available themes can be seen under: highlight/<...
David Soroko's user avatar
9 votes
Accepted

Nano - highlight trailing whitespaces

You can enable this for all filetypes which don't already have syntax highlighting defined by adding the following lines to .nanorc: syntax "default" color ,green "[[:space:]]+$" syntax "default" ...
muru's user avatar
  • 73k
8 votes

Debian editor with syntax highlight for DOT language

Vim has this built-in: https://github.com/vim/vim/blob/master/runtime/syntax/dot.vim. Mode for Emacs, can be installed from MELPA: https://github.com/ppareit/graphviz-dot-mode
Arkadiusz Drabczyk's user avatar
7 votes
Accepted

Joe's own editor: changing syntax highlighting

To be very specific and change the dark blue on black highlighting for PHP scripts in Joe: In Ubuntu 16.04 and with Joe 4.1-2, edit: /usr/share/joe/syntax/php.jsf And change: =Constant_sq blue ...
Alan's user avatar
  • 86
7 votes
Accepted

How can I run the syntax-highlighting.sh command for cgit to check it works properly?

It turns out that in order to get syntax highlighting working under cgit, the line specifying syntax highlighting must appear before the line for the repo locations. In the example given below, syntax ...
vfclists's user avatar
  • 7,531
7 votes
Accepted

Shell - Customize the color of each line of a log file based on a pattern

I would recommend a shell script, based on awk like Valentin B. solution: $ cat colorize awk ' function color(c,s) { printf("\033[%dm%s\033[0m\n",30+c,s) } /error/ {color(1,$0);next} /success/...
jlliagre's user avatar
  • 61.3k
6 votes

Shell - Customize the color of each line of a log file based on a pattern

awk, as mentioned in other answers, is definitely the tool to reach for first. But it isn't the only tool, by a long shot. A. L. Lambert's logtool is specifically designed for post-processing log ...
JdeBP's user avatar
  • 68.9k
6 votes
Accepted

command line tool to reserve code high light in output file?

ack does something smiliar to grep. When it puts it text to a terminal, it will spit the results out in color. If the output is redirected to a file, the matches do not get colorized. You can ...
joepd's user avatar
  • 2,397
6 votes

vim: Force specific syntax via command-line argument

vim -R -c 'set ft=sql' - -R opens Vim in read-only mode. Your system may have the alias view for vim -R, but Neovim does not support it. set ft is short for set filetype. As Martin Tournoij mentioned ...
anishpatel's user avatar
6 votes

Syntax highlighting in the terminal

If you're interested in colors in less more generally, you might want to look at lesspipe.sh. See, for example, http://freecode.com/projects/lesspipe. lesspipe.sh is an input filter for the pager ...
DaveEmme's user avatar
  • 386
4 votes

Syntax highlighting in the terminal

You can use bat: https://github.com/sharkdp/bat bat your_file acts as cat but pretty-prints the file contents, including file name, line numbers and syntax highlighting. There are options for piping ...
Jindra Helcl's user avatar
4 votes
Accepted

Diff patch output saved to a file. How to see it syntax-colored?

Any decent editor is able to highlight diffs conveniently. You can generally persuade your editor by using the .diff extension, or by setting the filetype to diff otherwise.
joepd's user avatar
  • 2,397
3 votes

Diff patch output saved to a file. How to see it syntax-colored?

You could hack something together that would read a line of the file, check the first char on the line, and print it in the appropriate color: green if the first char is a +, red if the first char is ...
Wildcard's user avatar
  • 36.6k
3 votes

What can bash do: syntax highlighting, git info prompt and autocomplete based on the middle of a word?

So far as I've seen: Syntax highlighting for commands: not so much in bash. git-aware prompt: yes if liquidprompt is installed. (liquidprompt can also be installed over zsh.) Autocompletion: ...
agc's user avatar
  • 7,233
3 votes

Change directory for Kate syntax highlighting files

For the latest version of Kate, placing syntax xml files in this directory works: ~/.local/share/katepart5/syntax Thanks @Datalore
Alexander's user avatar
  • 9,860
3 votes

.bashrc file syntax error near unexpected token `('

To restore the ~/.bashrc file: $ cp ~/.bashrc ~/.bashrc.velho $ cp /etc/skel/.bashrc ~/ $ source .bashrc
Jonatas Moreira's user avatar
3 votes
Accepted

Setting Vim to use shell syntax for dotfiles?

You can use the following in your .vimrc: autocmd BufNewFile,BufRead *.school_aliases,*.git_aliases set syntax=sh Or, you can set these file extensions to syntax types in ~/.vim/filetype.vim.
aliceinpalth's user avatar
  • 1,613
3 votes
Accepted

Using a bash array in an awk and also quoted variable: conflicting syntax issue

Syntax highlighting is one problem Each editor has its own dis-/advantages in this manner. See my question on SoftwareRecs and its respective answers, most importantly this for both CLI and GUI and ...
Vlastimil Burián's user avatar
3 votes
Accepted

Whois queries with color output

The program, grc, is "the frontend for generic colouriser grcat." The project exists at GitHub, but it might be installed from a repository, if your O/S has packaged the software. Many commands come ...
Christopher's user avatar
  • 15.9k
3 votes
Accepted

How to turn on syntax highlighting for vi/vim?

I think that your problem is your vim version: probably doesn't include syntax highlighting; try this: yum install vim-enhanced
alsjflalasjf.dev's user avatar
2 votes

Joe's own editor: changing syntax highlighting

Coloring files could also reside in /etc/joe/syntax/, just copy appropriate file to ~/.joe/syntax/ and edit it.
Joosep-Georg Järvemaa's user avatar
2 votes

How to change default syntax-highlighting for header-file in Kate

For kate 17.04.3 the directory of syntax is ~/.local/share/org.kde.syntax-highlighting/syntax
Arek Siwiec's user avatar
2 votes

Syntax highlighting in the terminal

I enjoy simplicity and I use nano text editor, in this case I usually proceed as follow: check witch syntax highlight is available: ls -la /usr/share/nano/ include it in my nanorc file with ...
lese's user avatar
  • 2,726
2 votes

vim: Force specific syntax via command-line argument

You can even automate that by putting the command into your ~/.vimrc: augroup filetype au! StdinReadPre * set filetype=sql augroup END
Murphy's user avatar
  • 2,649
2 votes
Accepted

Vim -- Syntax highlighting depending on whether whole line is commented

You cannot change the fold highlighting, as there's only one highlight group for all folds (:help hl-Folded). What you can do is indicate the "all comments"-nature of a fold via a custom fold-foldtext;...
Ingo Karkat's user avatar
  • 11.9k

Only top scored, non community-wiki answers of a minimum length are eligible