Is there a way to turn on python syntax highlighting for Terminal.app on Mac OS X?

| |
  • 2
    Do you mean inside the Python read-eval-print interpreter? – Lawrence Velázquez Mar 31 '10 at 5:38

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 or vim you want at least these option in ~/.vimrc

    syntax on
  • emacs works right out of the box

  • don't ask me about nano.
| |
  • include "/usr/share/nano/python.nanorc" - quite good. – user1686 Mar 31 '10 at 18:18

Try ipython. It highlights syntax and much more.
I haven't tried it on Mac but looks like it must work:

Another option is WxPython and pycrust (which works without Terminal.app :( )

| |

Here is a series of screencasts, that shows bpython in action:


| |
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Diogo Aug 9 '12 at 12:45
  • @Diogo, visiting the site will show that this link is to how-to videos. It's difficult to include essential parts in that respect. I agree that the answer needs work, but I don't think your comment is helpful. – user3463 Aug 12 '12 at 5:41
  • No problem Randolph, this comment was automatically posted by the review system when I reviewed it. – Diogo Aug 12 '12 at 14:19
  • It's gone now, however, and returns a 404, supporting @Diogo's point. – martin-martin Oct 19 '19 at 1:50

You can try ptpython in github, simply

pip install ptpython

and use it with ptpython.

| |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy