maandag 6 januari 2014

Nano syntax highlighting on OSX

This post explains you how to install syntax highlighting on Nano in OSX

If you haven't got it already install homebrew first. For info on homebrew 


After this you need to do a:

brew doctor

and fix the problems. (don't worry about the man pages) 
Now make sure the right repository is added: 
brew tap homebrew/dupes

And now install nano with brew:
brew install nano

Now edit the ~/.nanorc to:

set nowrap
set smooth
set autoindent
set backup
set historylog
set morespace
set tabsize 4
set tabstospaces
set mouse
set const
set backupdir "~/werk/backup/nano-backups"
include "/usr/local/share/nano/asm.nanorc"
include "/usr/local/share/nano/awk.nanorc"
include "/usr/local/share/nano/c.nanorc"
include "/usr/local/share/nano/cmake.nanorc"
include "/usr/local/share/nano/css.nanorc"
include "/usr/local/share/nano/debian.nanorc"b
include "/usr/local/share/nano/fortran.nanorc"
include "/usr/local/share/nano/gentoo.nanorc"
include "/usr/local/share/nano/groff.nanorc"
include "/usr/local/share/nano/html.nanorc"
include "/usr/local/share/nano/java.nanorc"
include "/usr/local/share/nano/makefile.nanorc"
include "/usr/local/share/nano/man.nanorc"
include "/usr/local/share/nano/mgp.nanorc"
include "/usr/local/share/nano/mutt.nanorc"
include "/usr/local/share/nano/nanorc.nanorc"
include "/usr/local/share/nano/objc.nanorc"
include "/usr/local/share/nano/ocaml.nanorc"
include "/usr/local/share/nano/patch.nanorc"
include "/usr/local/share/nano/perl.nanorc"
include "/usr/local/share/nano/php.nanorc"
include "/usr/local/share/nano/pov.nanorc"
include "/usr/local/share/nano/python.nanorc"
include "/usr/local/share/nano/ruby.nanorc"
include "/usr/local/share/nano/sh.nanorc"
include "/usr/local/share/nano/tcl.nanorc"
include "/usr/local/share/nano/tex.nanorc"
include "/usr/local/share/nano/xml.nanorc"

This should do the trick. 
It is possible that you bump into some errors like this:

Error in /usr/local/Cellar/nano/2.2.6/share/nano/mgp.nanorc on line 4: Command "header" not understood

Press Enter to continue starting nano.


Error in /usr/local/Cellar/nano/2.2.6/share/nano/perl.nanorc on line 4: Command "header" not understood

Press Enter to continue starting nano.


Error in /usr/local/Cellar/nano/2.2.6/share/nano/python.nanorc on line 4: Command "header" not understood

Press Enter to continue starting nano.


Error in /usr/local/Cellar/nano/2.2.6/share/nano/ruby.nanorc on line 4: Command "header" not understood

Press Enter to continue starting nano.


Error in /usr/local/Cellar/nano/2.2.6/share/nano/sh.nanorc on line 4: Command "header" not understood

Press Enter to continue starting nano.

This can mean two problems, the $PATH is not pointing to the new version of nano.
Start nano, see at the top if the version 2.2.6 is running. If not then type $PATH at the commandline you should see: /usr/local/bin at the beginning of the line. If not then edit /ets/paths so the /usr/local/bin is on top. This should solve it. 

Just go to:  https://github.com/Munter/dotfiles/tree/master/.nano and get this missing files and add them. 

2 opmerkingen:

  1. Awesome stuff, pal! Came in very useful.

    Thanks from Córdoba, Argentina! :D

    BeantwoordenVerwijderen
  2. In your nanorc text you've set the backup directory to an absolute path. This will mis-configure nano to use a path which doesn't exist on anyone's machine aside from one with a user called "werk"
    set backupdir "~/werk/backup/nano-backups"

    BeantwoordenVerwijderen