2016-12-10 10:50:00 +01:00
|
|
|
#!/bin/sh
|
2019-10-27 21:17:37 +00:00
|
|
|
|
|
|
|
# IMPROVED NANO SYNTAX HIGHLIGHTING FILES
|
|
|
|
# Get nano editor better to use and see.
|
|
|
|
|
|
|
|
# Copyright (C) 2014+ Anthony Scopatz et al.
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or (at
|
|
|
|
# your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
# General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
2016-12-10 10:50:00 +01:00
|
|
|
|
2018-07-14 19:16:55 -04:00
|
|
|
# check for unzip before we continue
|
|
|
|
if [ ! "$(command -v unzip)" ]; then
|
|
|
|
echo 'unzip is required but was not found. Install unzip first and then run this script again.' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-03-29 12:52:08 -04:00
|
|
|
_fetch_sources(){
|
2017-02-21 09:25:43 -03:00
|
|
|
wget -O /tmp/nanorc.zip https://github.com/scopatz/nanorc/archive/master.zip
|
2019-06-24 12:21:11 +02:00
|
|
|
mkdir -p ~/.nano/
|
2015-12-14 22:02:50 -05:00
|
|
|
|
2017-12-28 01:29:50 -05:00
|
|
|
cd ~/.nano/ || exit
|
2017-02-21 09:25:43 -03:00
|
|
|
unzip -o "/tmp/nanorc.zip"
|
|
|
|
mv nanorc-master/* ./
|
|
|
|
rm -rf nanorc-master
|
|
|
|
rm /tmp/nanorc.zip
|
|
|
|
}
|
2015-12-14 22:02:50 -05:00
|
|
|
|
2017-03-29 12:52:08 -04:00
|
|
|
_update_nanorc(){
|
2019-06-24 12:21:11 +02:00
|
|
|
touch ~/.nanorc
|
2019-10-03 23:06:15 +01:00
|
|
|
|
2017-02-21 09:25:43 -03:00
|
|
|
# add all includes from ~/.nano/nanorc if they're not already there
|
2017-12-28 01:29:50 -05:00
|
|
|
while read -r inc; do
|
2017-02-21 09:25:43 -03:00
|
|
|
if ! grep -q "$inc" "${NANORC_FILE}"; then
|
2017-12-28 01:29:50 -05:00
|
|
|
echo "$inc" >> "$NANORC_FILE"
|
2017-02-21 09:25:43 -03:00
|
|
|
fi
|
|
|
|
done < ~/.nano/nanorc
|
|
|
|
}
|
|
|
|
|
2017-03-29 12:52:08 -04:00
|
|
|
_update_nanorc_lite(){
|
2017-02-21 09:25:43 -03:00
|
|
|
sed -i '/include "\/usr\/share\/nano\/\*\.nanorc"/i include "~\/.nano\/*.nanorc"' "${NANORC_FILE}"
|
|
|
|
}
|
2015-12-14 22:02:50 -05:00
|
|
|
|
2019-10-27 21:17:37 +00:00
|
|
|
# Good start / docs
|
|
|
|
# start constants
|
|
|
|
# list and check the needed programs
|
|
|
|
# check parameters
|
|
|
|
# init main
|
|
|
|
# get the git
|
|
|
|
# updat/create the nanorc
|
|
|
|
|
2016-12-10 10:50:00 +01:00
|
|
|
NANORC_FILE=~/.nanorc
|
2017-02-21 09:25:43 -03:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
-l|--lite)
|
2019-06-24 12:21:11 +02:00
|
|
|
UPDATE_LITE=1;;
|
2017-02-21 09:25:43 -03:00
|
|
|
-h|--help)
|
2019-06-24 12:21:11 +02:00
|
|
|
echo "Install script for nanorc syntax highlights"
|
|
|
|
echo "Call with -l or --lite to update .nanorc with secondary precedence to existing .nanorc includes"
|
2017-02-21 09:25:43 -03:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
_fetch_sources;
|
2017-03-29 12:52:59 -04:00
|
|
|
if [ $UPDATE_LITE ];
|
|
|
|
then
|
|
|
|
_update_nanorc_lite
|
2017-02-21 09:25:43 -03:00
|
|
|
else
|
2017-03-29 12:52:59 -04:00
|
|
|
_update_nanorc
|
2017-02-21 09:25:43 -03:00
|
|
|
fi
|