How do you reinstall nano on Mac OS X?

I accidentally overwrote my nano app with a unix binary version, and now nano doesnt work on my Mac OS (Maverick).

How do I restore nano or get it back?

I couldnt find it on homebrew and I don't know beans about compiling src files.

Nano error when trying to use git

/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git-rebase--interactive: line 225: /usr/bin/nano: cannot execute binary file
Could not execute editor

  1. Download the nano source (I recommend the tar.xz one) (nano-editor.org/download.php)
  2. Go to the folder it was downloaded to (By default it downloads to ~/Downloads but if you changed the directory where files download then just go there).
  3. Extract the nano source you downloaded.
  4. Open your terminal
  5. Type "cd " without the "" then drag and drop the folder you extracted and click enter.
  6. run "./configure" without the "".
  7. run "make" without the "".
  8. run "sudo make install" without the "".]

You have now successfully installed nano!


Update: The answer below is no longer accurate. As of Apr 4, 2017, the formulae were moved to homebrew/core. See https://github.com/Homebrew/homebrew-dupes/commits/master/README.md


The reason you can't find it in homebrew is because homebrew's main repo doesn't include programs that come with the OS. You have to add an additional repo:

brew tap homebrew/dupes
brew install nano

https://github.com/Homebrew/homebrew-dupes