Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nano settings are not adopted from nanorc file

I have a new Macbook M1 and usually edit files and write short scripts with nano. However, I am stuck in default settings, which are of course not really feasible. I created a file ~/.nanorc and since it didn't work also a file ~/etc/nanorc with the following content:

set linenumbers
set tabsize 4
set tabstospaces
unset mouse

Unfortunately, it has no effect. I don't remember, if I faced the same problem when customising nano at my old macbook. Can someone help me out here?

Thanks!!

like image 570
spadel Avatar asked Sep 11 '25 06:09

spadel


2 Answers

I was having the same issue after I installed nano using brew (Monterey on M1). It turned out that nano command is by default symlinked to pico editor in /usr/bin, see https://ss64.com/osx/pico.html.

You can try checking if that is the case for you by using which nano. In my case it was pointing to /usr/bin/nano which is actually just symlink to pico (you can check this with readlink /usr/bin/nano)

This is probably an issue with homebrew, check this post Homebrew: Could not symlink, /usr/local/bin is not writable

As a quick fix (to verify if this is actually the case) you can just create a symlink pointing to homebrew installation of nano: ln -s /opt/homebrew/bin/nano /usr/local/bin/nano.
This should open nano instead of pico when using nano command and settings in .nanorc should now also be taken into account.

like image 162
Nik Avatar answered Sep 13 '25 21:09

Nik


Seconded Nik's answered above. It worked on my Mac M2(Ventura 13.4). I had to do extra steps which learnt from here: https://unix.stackexchange.com/questions/501862/how-can-i-set-the-default-editor-as-nano-on-my-mac

Details:

$brew install nano
$sudo ln -s /opt/homebrew/bin/nano /usr/local/bin/nano

Put these in .zshrc

export EDITOR=/usr/local/bin/nano
export VISUAL="$EDITOR"

then restart the terminal, $which nano gives me /opt/homebrew/bin/nano. It also reflects setting my in ~/.nanorc.

--

I end up achieving the same without the link, just replace with export EDITOR=/opt/homebrew/bin/nano

(can kill the softlink by $sudo unlink /usr/local/bin/nano)

like image 41
meswwill Avatar answered Sep 13 '25 22:09

meswwill