5

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

1
  • 2
    Do you mean inside the Python read-eval-print interpreter? Mar 31, 2010 at 5:38

3 Answers 3

7

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.
1
  • include "/usr/share/nano/python.nanorc" - quite good.
    – user1686
    Mar 31, 2010 at 18:18
2

You can try ptpython in github, simply

pip install ptpython

and use it with ptpython.

1

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 :( )

Your Answer

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