How to color the Python syntax in nano

Solution 1:

Nano is perfectly fine as a simple code editor. It has wonderful syntax highlighting. You will probably want an up-to-date version of nano.

  1. Install homebrew: https://brew.sh/
  2. Install nano: brew install nano
  3. Add this line to ~/.nanorc. That directory has all the syntax highlighting definition files.

    include "/usr/local/share/nano/*.nanorc"
    

Solution 2:

It seems like the default version of nano included with OS X is very basic; it may not support syntax highlighting.

(source: https://gist.github.com/BlakeGardner/5587269)

You could try installing an updated version of nano using homebrew and then find instructions for enabling colors.

See also this stack overflow answer regarding installing updated nano.

Alternatively, you could also try a different editor such as TextMate, Emacs, or Vim. These editors will have additional convenience features like auto indentation.