I've got nano 2.0.6 as default in my Mac OS X terminal when executing
I've got nano 2.9.1 in
How do I change the default
nanoto version 2.9.1 in the terminal?
I'm running Mac OS X 10.13.1.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
This another answer is good, especially as a temporary override. For the sake of completeness this is the main point of it:
The problem is: if you need a permanent solution for multiple tools then with such a simple approach your
$PATH will unnecessarily bloat.
This is how to avoid this (on Debian; the question is for Mac OS X but I believe the solution also applies or can be easily adapted). First create your own
(Edit: on macOS,
~/Library/bin/ fits the home folder organization a bit better. I decided not to change my answer though, adapt this path to your needs.)
Next modify your
(See note 1 down below if you want to make it permanent.)
Then symlink the desired
nano (and any other binary) to your custom
ln -s /usr/local/Cellar/nano/2.9.1/bin/nano ~/bin/
(See note 2 down below if you want to use this
nano right away.)
This approach has the following advantages:
$PATHstays relatively short and clean;
ls -l ~/bin/you can easily tell which tools you do override with what; this is much better than analyzing a bloated
$PATHwhich specifies directories; every directory may include many executables and you need to
lsanyway to know them;
$PATH, especially from within a script;
Note 1: in my Debian the
/etc/skel/.profile includes the following code:
# set PATH so it includes user's private bin if it exists if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH" fi
~/.profile was created as a copy of
/etc/skel/.profile, so the code is there from the very beginning. This means every new shell session adjusts its
$PATH to include my private
bin/; all I had to do was create the directory.
Note 2: while modifying
$PATH in the middle of a session (e.g. to test my solution) keep in mind your shell may remember the old location of any executable it had already looked up according to the old
$PATH. Common shells use
hash builtin to manage this. Use
hash -r if needed.
If you customize
$PATH at the very beginning of a shell session (like in
.profile) then there's no such problem.
You can create a symbolic link from
ln -s /usr/local/Cellar/nano/2.9.1/bin/nano /usr/local/bin/nano
or you could create an alias.
does the trick.