-
-
Save fevangelou/be744753730e86b8783fd481f311a7c9 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# Install Nano Editor (with syntax highlighting) on MacOS without using Homebrew | |
# You can get the latest version number from https://www.nano-editor.org | |
# Instructions: | |
# - First off, download this Bash script from the browser & make it executable: | |
# $ chmod +x install_nano_on_macos_without_homebrew.sh | |
# - If you have "wget" installed (you most likely do), just run the script with: | |
# $ ./install_nano_on_macos_without_homebrew.sh | |
# ...and you're ready. | |
# - If you don't have "wget" installed, download the latest release of the Nano Editor in *.tar.gz | |
# from https://www.nano-editor.org and make sure the version referenced in the *.tar.gz file is also | |
# referenced in the VERSION specified after these comments & then run the script with: | |
# $ ./install_nano_on_macos_without_homebrew.sh | |
# ...which will use the file your downloaded for the Nano Editor to install it directly. | |
VERSION="7.2" # As of Jan 2024 - set the version number here | |
cd ~/Downloads | |
if [ ! -f "nano-${VERSION}.tar.gz" ]; then | |
wget -O nano.tar.gz https://www.nano-editor.org/dist/latest/nano-${VERSION}.tar.gz | |
fi | |
tar -xvf nano.tar.gz | |
mv nano ~/.nano | |
cd ~/.nano | |
./configure | |
make | |
sudo make install | |
touch ~/.nanorc | |
cat > "~/.nanorc" <<EOF | |
## Some defaults | |
set autoindent | |
set historylog | |
set indicator | |
set linenumbers | |
set locking | |
set mouse | |
set softwrap | |
set stateflags | |
set tabsize 4 | |
set tabstospaces | |
## Enable syntax highlighting in Nano | |
include ~/.nano/syntax/*.nanorc | |
EOF | |
exit |
Thanks. I did it already like above and added the alias in the bashrc like suggested above. Works perfectly.
#!/usr/bin/env bash # Install nano editor https://www.nano-editor.org/dist/v4/nano-4.9.3.tar.xz Modified: 2020 May 23 VERSION="4.9.3" NANO_SHORT="nano-$VERSION" NANO_SRC="$NANO_SHORT.tar.xz" NANO_URL="https://www.nano-editor.org/dist/v4" NANO_EXTRA="https://github.com/scopatz/nanorc" cd ~/ wget $NANO_URL/$NANO_SRC tar -zxvf $NANO_SRC mv $NANO_SHORT .nano && cd .nano/ ./configure && make && sudo make install git clone --depth=1 $NANO_EXTRA syntax_improved cd ~/ && touch .nanorc echo "# Enable syntax highlighting in Nano" >> $HOME/.nanorc echo "include ~/.nano/syntax/*.nanorc" >> $HOME/.nanorc echo "include ~/.nano/syntax_improved/*.nanorc" >> $HOME/.nanorc rm -vf $NANO_SRC printf "\nExit terminal and reopen using $NANO_SHORT\nTo unistall it and revert to old:\ncd ~/.nano && sudo make\n" exit
@a3igner It should work fine now, the problem was in the creation of the nanorc
Works on 11.0 Beta 2, thank you!
Hello, what’s about nano on IPadOS, sir? I try install this pakage in NewTerm mobile but not working!
Hello, what’s about nano on IPadOS, sir? I try install this pakage in NewTerm mobile but not working!
Does iPadOS even has a terminal? LOL! I'll check this information and the possibility of installing "nano" to a non-jailbroken iOS environment
@homogulosus i just tried this on a fresh catalina install and your script didnt work.
Try to edit .nanorc file manually and add
# Enable syntax highlighting in Nano
include ~/.nano/syntax/*.nanorc
Hi,
I run the code chunk above on terminal and I got error below. Would anyone please tell me how to fix it? Thank you so much!
Error in /Users/Chris/.nano/syntax_improved/zig.nanorc on line 2: Color "latte" not understood
Error in /Users/Chris/.nano/syntax_improved/zig.nanorc on line 9: Command "tabgives" not understood
Error in /Users/Chris/.nano/syntax_improved/rego.nanorc on line 15: Color "purple" not understood
Error in /Users/Chris/.nano/syntax_improved/Rnw.nanorc on line 19: Bad regex "([a-zA-Z0-9_-$.])(": Invalid range end
Error in /Users/Chris/.nano/syntax_improved/zig.nanorc on line 2: Color "latte" not understood
Error in /Users/Chris/.nano/syntax_improved/zig.nanorc on line 9: Command "tabgives" not understood
Error in /Users/Chris/.nano/syntax_improved/rego.nanorc on line 15: Color "purple" not understood
Error in /Users/Chris/.nano/syntax_improved/Rnw.nanorc on line 19: Bad regex "([a-zA-Z0-9_-$.])(": Invalid range end
This script was written for the Bash shell. My guess is you're on Zsh (the new shell used in macOS).
In any case, since this guide was written some time ago, I would recommend installing Homebrew and then just do brew install nano
and you're done.
Hi @fevangelou
I brew install nano
then bash
and even update to nano 4.0 but I still got that error. I switch from zsh to bash.
@a3igner It should work fine now, the problem was in the creation of the nanorc