1
0
mirror of https://github.com/scopatz/nanorc synced 2024-11-05 09:10:00 +01:00
nanorc/install.sh
CSRedRat 7420c6e693
fix script run on Ubuntu 18.04
inflating: nanorc-2.9/zsh.nanorc
    linking: nanorc-2.9/zshrc.nanorc  -> zsh.nanorc
finishing deferred symbolic links:
  nanorc-2.9/gitcommit.nanorc -> git.nanorc
  nanorc-2.9/html.j2.nanorc -> html.nanorc
  nanorc-2.9/zshrc.nanorc -> zsh.nanorc
+ mv 'nanorc-v2.9/*' ./
mv: cannot stat 'nanorc-v2.9/*': No such file or directory
+ rm -rf nanorc-v2.9
+ rm /tmp/nanorc.zip
+ '[' ']'
+ _update_nanorc
+ touch /c/Users/home/.nanorc
install.sh: line 20: /c/Users/home/.nano/nanorc: No such file or directory
2020-08-12 04:15:44 +05:00

53 lines
1.1 KiB
Bash
Executable File

#!/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
mkdir -p ~/.nano/
cd ~/.nano/ || exit
unzip -o "/tmp/nanorc.zip"
mv nanorc-2.9/* ./
rm -rf nanorc-2.9
rm /tmp/nanorc.zip
}
_update_nanorc(){
touch ~/.nanorc
# add all includes from ~/.nano/nanorc if they're not already there
while read -r inc; do
if ! grep -q "$inc" "${NANORC_FILE}"; then
echo "$inc" >> "$NANORC_FILE"
fi
done < ~/.nano/nanorc
}
_update_nanorc_lite(){
sed -i '/include "\/usr\/share\/nano\/\*\.nanorc"/i include "~\/.nano\/*.nanorc"' "${NANORC_FILE}"
}
NANORC_FILE=~/.nanorc
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;
if [ $UPDATE_LITE ];
then
_update_nanorc_lite
else
_update_nanorc
fi