Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Install nano, an enhanced pico text editor UNIX
Many of you will probably be aware of pico, the lightweight text-editor that comes with OS X. While there are very powerful text editors available, such as emacs and vi, pico still remains a great editor for simple text editing and beginning programmers, due to its intuitive interface.

Nano is a GNU project that is an enhanced version of pico, which retains its easy-to-use interface with some very useful features- including find-and-replace, go to a specific line number (both very useful for programming), justify text, continuous display of cursor position (line number and character number), case-sensitive-search, tab-completion when saving or reading, etc. Also, common functions are now mapped to the Fx function keys, F1 is help, F2 is quit, F7 and F8 scroll the page up and down, F9 and F10 cuts and pastes the current line, etc. The current unstable development versions allow color syntax highlighting and support for multiple file-buffers.

Note: Some features use the meta-key which doesn't exist on mac keyboards, so you will need to press the escape key then the desired letter when accessing some features, for example escape the 'c' for constant display of cursor position.

To install pico, download the source from the Nano homepage, then navigate to the source directory and type
 %./configure
% make
% sudo make install
[Editor's note: I downloaded the 1.09.tgz source (444K download), and it compiled and ran perfectly. Looks like a nice pico replacement!]
    •    
  • Currently 2.75 / 5
  You rated: 1 / 5 (4 votes cast)
 
[35,285 views]  

Install nano, an enhanced pico text editor | 29 comments | Create New Account
Click here to return to the 'Install nano, an enhanced pico text editor' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Thanks
Authored by: Glanz on Oct 17, '02 11:39:00AM

Can't thank you enough!!! I have used Nano before in Debian and in FreeBSD, and I'm a big fan of Pico and Pine...... This is going to come in handy. BTW, to which directory did you install? And do man pages come with it? If they do, I sure cant find them!



[ Reply to This | # ]
Also available through fink
Authored by: Titanium Man on Oct 17, '02 11:44:13AM

Also available through fink:

% fink list | grep nano
nano 1.0.9-11 Improved clone of the Pico text editor



[ Reply to This | # ]
Some possible arguments
Authored by: c15zyx on Oct 17, '02 01:40:15PM

For programmers: start nano with the -c and -i arguments, -c automatically turns on cursor position display and -i turns on auto-indent, which indents the next line the same amount as the previous.

Glanz: installs in /usr/local unless you set --prefix. Also, man pages do come with it, do man nano.



[ Reply to This | # ]
Some possible arguments
Authored by: Glanz on Oct 17, '02 01:49:50PM

man nano gives nothing!



[ Reply to This | # ]
Some possible arguments
Authored by: c15zyx on Oct 17, '02 02:01:24PM
oh, well it works on mine, maybe your --mandir was wrongly set on configure?

[From the editor: I trimmed the posted "man" page due to length and Geeklog's poor formatting options. When someone asks about man pages in the future, there are numerous onlin resources available which do nothing more than catalog UNIX man pages. In this case, though, since it's a GNU project, you can use nano's own online manual pages to review the manual. -rob.]

[ Reply to This | # ]
Thaaaaaaaaaanks:)
Authored by: Glanz on Oct 17, '02 02:56:03PM
My nano man page is in /usr/local/man/man1/nano.1 but the only way I have to open it is by naviguating to the file via TextEdit..... No paths for manual pages for user-installed stuff on my OS10.2.1 work. I tried writing them myself like I used to do sometimes in FreeBSD, but that doesn't work either. Thanks again.

[Editor's note: I trimmed the "man" page here, too ... see the above note for a reference to an online version. -rob.]

[ Reply to This | # ]
Thaaaaaaaaaanks:)
Authored by: macmike42 on Oct 17, '02 05:18:05PM

Seriously, is posting man pages in the comments necassary? To get rid of all those extra characters, do "man <manpagename> | col -b" to get nice clean ASCII output.



[ Reply to This | # ]
Thaaaaaaaaaanks:)
Authored by: Glanz on Oct 18, '02 12:17:44AM

If you don't loke it, just ignore it by scrolling. I do not apologize, nor do I intend to.



[ Reply to This | # ]
Now what
Authored by: jschank on Oct 17, '02 04:37:41PM

Hi there,
I don't want to sound too ignorant, but this is my first attempt at building a project on my Mac.
The instructions seemed to work fine, but I cannot seem to run the program. It says nano: Command not found. when I try to run it.
Could this be because for sudo I used an admin password instead of the root password?
Thanks,
John Schank



[ Reply to This | # ]
Now what
Authored by: macmike42 on Oct 17, '02 05:21:13PM

tcsh (the default Mac OS X shell) doesn't actually hunt for the command you've typed, but rather consults a cache of available commands. If you are still in the same shell you are in after installing a new program, type "rehash" to force tcsh to rebuild the cache. The alternative is to open a new shell/terminal window.



[ Reply to This | # ]
Now what
Authored by: Glanz on Oct 17, '02 05:27:50PM

I had to place an alias in my ".tcshrc" file in the home directory, and I had to write out the full path, as is done in BSD & Linux:
"alias nano /usr/local/bin/nano"
That will make it run... or you can type the path to it in a terminal window "/usr/local/bin/nano" or you can make a symlink



[ Reply to This | # ]
Now what
Authored by: mervTormel on Oct 17, '02 05:27:59PM

i suspect that /usr/local/bin is not in your path.



[ Reply to This | # ]
Now what
Authored by: jschank on Oct 17, '02 05:47:31PM

Hi again,

Thanks for the replies. But still no luck.
I didn't have a .tcshrc file in my home directory, so I created one with the alias command mentioned... No change.
I tried actually changing my CWD to /usr/local/bin typing nano<enter> still said command not found.
I did an ls, and the file is there.
I checked my path via echo $path, and as mentioned /usr/local/bin is not in the path. So, New question, How do I edit my path???
Thanks,
John



[ Reply to This | # ]
Now what
Authored by: babbage on Oct 17, '02 10:53:51PM

If the current working directory isn't in your path, then changing to /usr/local/bin wouldn't be enough either. The usual solutions are [a] add "." to your PATH environment variable (this is generally frowned on for security reasons, but is awfully convenient and I don't blame people for liking the setting), [b] prefix these commands with a dot-slash "./", which effectively fills in the full path for the shell (relatively simple, and not a security issue like the first option), or [c] run the command with the full path -- /usr/local/bin/nano.

Like others have said, you need to reload your command cache with "rehash", and make sure that /usr/local/bin is in your path with "printenv PATH". As a last ditch test you can try launching /usr/local/bin/nano directly, which should work regardless of your PATH or command cache, but really those need to be fixed. The alias will also work, but it's a "papering over the cracks" solution that treats the symptom, not the disease. In the long run it's better to just fix your PATH rather than add aliases for every single command...



[ Reply to This | # ]
Thank You very much!
Authored by: Glanz on Oct 20, '02 09:51:06AM

Well, after all my trouble, I switched to the zsh shell via the chsh command and corrected my paths there so that all worked well, then I did the same with bash. I came back to tcsh to do the same and all worked well, but in tcsh I had to use the "./", unlike the other shells. Thank you again! I really appreciated your little reminder! Zsh and Bash are the shells with which I am most comfortable, but tcsh has its advantages too, since it is the default shell for OS X.



[ Reply to This | # ]
Now what - Update
Authored by: jschank on Oct 17, '02 05:53:09PM

Apparently, I spoke too soon. A new shell, and (I guess) the alias seems to work.
Thanks, For the help!
BTW, How do I edit my path?



[ Reply to This | # ]
Now what - Update
Authored by: matt_j_gray on Oct 17, '02 07:02:24PM

To edit your path (and other things), you can start by reading

/usr/share/tcsh/examples/README

and looking at the files in that directory.

To add something to your path in tcsh, try

setenv PATH new/thing/to/add:$PATH

This will add the new directory to the front of your PATH, keeping the old stuff as well.



[ Reply to This | # ]
Get the latest CVS version
Authored by: iMMersE on Oct 17, '02 07:37:26PM
If you are familiar with CVS, and like to live on the edge, you should get the version of Nano in CVS (Currently 1.1.11-CVS). It has a bunch of extra features over 1.0.9 - Below you can see the NEWS.

Warning though, you have to have pretty recent versions of automake/autoconf/m4 and you still need to tweak a couple of files. If anyone needs more details (Or just the a .tar.gz so you can install it in the same manner as above), feel free to drop me an email. I still prefer Jed though :)
10/01/2002 - GNU nano 1.1.11 "Oddball" is released. This release features a new version of gettext, a new and improved syntax highlighting engine, and some updates for the nanorc.sample file. The toggles for case sensitivity (Meta-C) and regular expressions (Meta-R) have changed in the search and replace prompts, multibuffer status is now displayed and can be toggled from the insert file menu, and some wrapping behavior that changed in 1.1.10 has reverted. The --enable-color warning was also made less severe, as the color syntax code has improved, and nano now uses extended regexes in the .nanorc file.

Also included are fixes for various memory leaks, the operating directory option, username tab completion, the page_up and down arrow, go to previous word and next word, nanorc parser and line wrapping code. Have fun!

07/25/2002 - At long last! GNU nano 1.1.10 "What didn't we break?" is released. This version of GNU nano features version 0.11.2 of gettext, building with automake 1.6, some new code for displaying control characters, browser improvements, a new backup file option (-B, --backup), a new option to ignore rc files (-I,--ignorercfiles), compatibility with -pedantic, handling null characters before EOF, a slightly sportier nanorc.sample and more.

Fixes are included included for justification, the reading and writing file routines, resizing and fill length, millions of memory leaks, the usage screen was updated, and the the --quotestr and --regexp really work now ;-) Enjoy :)
[Editor's note: I cleaned up the formatting on this one, but made no changes to the content.]

[ Reply to This | # ]
$
Authored by: Glanz on Oct 18, '02 12:15:00AM

I am having a really lot of difficulty setting the paths on this one. There is never, never an automatically installed path to a newly installed make. Man files on newly installed apps do not respond to the "man" command. I had to resort to writing full paths with aliases in the ".tcshrc" ~ file. For some reason, Jaguar just does not accept any path I write. I have never had this problem in Linux, BSD, or Darwin. Even with aliases, I had to write, save, rehash, rewrite, etc five times before I could get Nano, Vim, and mc to launch. No paths...., just aliases. The terminal just ignores written paths. Believe me, I have read all I could read on paths in the FreeBSD handbook, Unix for OS X, The Missing Manual, etc..... Nothing works.



[ Reply to This | # ]
$
Authored by: iMMersE on Oct 18, '02 08:26:40AM

This is what I have included in my .tcshrc, and it works fine.

set path = ( $path /usr/local/bin /usr/local/mysql/bin )
setenv MANPATH /usr/local/man:${MANPATH}

(Ignore the mysql part of the first line if you don't need it)

Setting the path in this way also sets the environment variable PATH (and vice versa actually). I'm not sure what isn't working in your case, as it sounds like you know what you're doing, but if you try the above and it doesn't work, post another message here and we can try and fix it for you :)



[ Reply to This | # ]
$
Authored by: bjast on Oct 18, '02 09:44:43AM

When I used the ./Configure command this is what it returned:

[Bill:/Applications/nano-1.0.9] bjast% ./Configure
loading cache ./config.cache
checking for a BSD compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... no
checking for working aclocal... found
checking for working autoconf... missing
checking for working automake... found
checking for working autoheader... missing
checking for working makeinfo... found
checking for gcc... no
checking for cc... no
configure: error: no acceptable cc found in $PATH

Somethings broke, but I have no idea what.



[ Reply to This | # ]
./configure problems
Authored by: iMMersE on Oct 18, '02 10:27:01AM

I'm guessing from error message that that you don't have the Developer tools installed? You'll need them to compile.



[ Reply to This | # ]
$
Authored by: Glanz on Oct 18, '02 12:05:20PM

Looks like we got some interesting problens here. I think I'll take a trip into BASHland via the "chsh" command and see what I can do with ba$h with which I am much more familiar.



[ Reply to This | # ]
$
Authored by: Glanz on Oct 18, '02 11:35:36AM

No..., it doesn't work. The man pages are there in /usr/local/man and /usr/share/man but adding the path has no effect at all. Oh well! If this keeps up I am going back to bash $$$$$$ and dumping the %%%%%%%%% :):):)



[ Reply to This | # ]
$
Authored by: Glanz on Oct 18, '02 05:44:54PM

I went to BASH. I no longer have any problems setting paths. I am beginning to believe that tcsch sucks.



[ Reply to This | # ]
Sourcing the PATH
Authored by: Glanz on Oct 20, '02 02:30:06PM

As I stated in my previous general message, I had a lot of trouble setting the paths to launch newly installed Unix apps. I temporarily went into the Ba$h and the zsh shells to set them for those respective shells. When I came back to tcsh, I discovered that everything worked perfectly. For some reason I can't figure out the sourcing wouldn't work until I quit the shell and come back to it. A mystery perhaps, or little BSD deamons having fun, or simply my incompetence.:) I found that in my case, sourcing the file in which I would write my paths was better done BEFORE I wrote the paths. Now that's backwards I know. Blame it on the daemons again!



[ Reply to This | # ]
Linefeeds showing
Authored by: bluehz on Oct 22, '02 08:38:11AM

I had no problems installing nano on both my OS X box and Linux box. One problem though - when viewing files - even standard unix (e.g. not created on Mac) files opened in nano display the linefeed characters....like this:

chmod u+w $CODEREDHOSTSFILE^M
^M
^M
^M

Is there anyway to turn off the display of the linefeeds? Its rather distracting...

FYI - although it is not recommended to create aliases that mimic real cmds - I created an alias called "pico" that points to nano...I am so used to using pico that its second nature to type it -this way even if I type it I get nano instead.



[ Reply to This | # ]
Linefeeds showing
Authored by: Glanz on Oct 23, '02 08:01:28AM

Yes... there is a way! This is a problem of translating formats and is easily solved.

To fix it, type the following commands in the shell very carefully:

% echo alias m2u tr '\015' '\012' >> ~/.cshrc
% echo alias u2m tr '\015' '\012' >> ~/.cshrc

Then type:
% source ~/.cshrc

After, when working with Unix editing tools and you need to fix a Mac format file, use m2u [mac to unix] as follows
% m2u < mac-format-file > unix-friendly-file

And when you're editing a Unix file in a Mac tool and there is carriage return jibberish, use the reverse:
% u2m < unix-friendly-file > mac-format-file

The "tr" command is also helpful. See: "man tr"...



[ Reply to This | # ]
Nano Info 4 y'all
Authored by: Glanz on Oct 23, '02 02:01:35PM

Here's some excellent sources of info about Nano. Of course, the Nano man page is excellent too.

http://www.nano-editor.org/docs.html

http://www.nano-editor.org/dist/v1.0/nano.html is the Nano Command Manual



[ Reply to This | # ]