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