Syntax Highlighting in Terminal for Python?
Solution 1
If you just want to highlight sources you dump into the terminal a la cat
try excellent pygments. It actually supports a lot of languages. Run with
pygmentize source.py
If instead you were talking about editing files with syntax highlighting inside a mac terminal, this really depends on the editor.
-
for
vi
orvim
you want at least these option in~/.vimrc
syntax on
emacs
works right out of the box- don't ask me about
nano
.
Solution 2
You can try ptpython
in github, simply
pip install ptpython
and use it with ptpython
.
Solution 3
Try ipython. It highlights syntax and much more.
I haven't tried it on Mac but looks like it must work:
https://stackoverflow.com/questions/726449/installing-ipython-with-readline-on-the-mac
Another option is WxPython and pycrust (which works without Terminal.app :( )
Related videos on Youtube
studiohack
Updated on September 17, 2022Comments
-
studiohack over 1 year
Is there a way to turn on python syntax highlighting for Terminal.app on Mac OS X?
-
Lawrence Velázquez about 14 yearsDo you mean inside the Python read-eval-print interpreter?
-
-
user1686 about 14 years
include "/usr/share/nano/python.nanorc"
- quite good.