1
0
mirror of https://github.com/scopatz/nanorc synced 2024-11-16 14:14:15 +01:00
nanorc/install.sh

53 lines
1.1 KiB
Bash
Raw Normal View History

#!/bin/sh
# 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
_fetch_sources(){
wget -O /tmp/nanorc.zip https://github.com/scopatz/nanorc/archive/v2.9.zip
2019-06-24 12:21:11 +02:00
mkdir -p ~/.nano/
2015-12-15 04:02:50 +01:00
2017-12-28 07:29:50 +01:00
cd ~/.nano/ || exit
unzip -o "/tmp/nanorc.zip"
mv nanorc-v2.9/* ./
rm -rf nanorc-v2.9
rm /tmp/nanorc.zip
}
2015-12-15 04:02:50 +01:00
_update_nanorc(){
2019-06-24 12:21:11 +02:00
touch ~/.nanorc
# add all includes from ~/.nano/nanorc if they're not already there
2017-12-28 07:29:50 +01:00
while read -r inc; do
if ! grep -q "$inc" "${NANORC_FILE}"; then
2017-12-28 07:29:50 +01:00
echo "$inc" >> "$NANORC_FILE"
fi
done < ~/.nano/nanorc
}
_update_nanorc_lite(){
sed -i '/include "\/usr\/share\/nano\/\*\.nanorc"/i include "~\/.nano\/*.nanorc"' "${NANORC_FILE}"
}
2015-12-15 04:02:50 +01:00
NANORC_FILE=~/.nanorc
case "$1" in
-l|--lite)
2019-06-24 12:21:11 +02:00
UPDATE_LITE=1;;
-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"
;;
esac
_fetch_sources;
if [ $UPDATE_LITE ];
then
_update_nanorc_lite
else
_update_nanorc
fi