#!/bin/bash
#

BASEDIR="/etc/custom"
BASHFILE="/etc/bash.bashrc"
BASHFILEORIG="/etc/custom/bashrc_debian"
BLESHCONF="/etc/custom/blesh/blesh.conf"

mkdir -p $BASEDIR

#cleanup
rm -rf $BASEDIR/blesh
rm -rf $BASEDIR/bash-powerline-ng

cd $BASEDIR

curl -L https://github.com/akinomyoga/ble.sh/releases/download/nightly/ble-nightly.tar.xz | tar xJf -
mv ble-nightly blesh

chown -R root:root blesh

wget -O bashrc_append https://download.al1al7.de/vim/bashrc_append.txt
wget -O bashrc_debian https://download.al1al7.de/vim/bashrc_debian.txt
wget -O $BLESHCONF https://download.al1al7.de/vim/blesh.conf

if [ ! -f  /usr/lib/python3/dist-packages/ranger/colorschemes/default_backup.py ]; then
	mv /usr/lib/python3/dist-packages/ranger/colorschemes/default.py /usr/lib/python3/dist-packages/ranger/colorschemes/default_backup.py
fi
rm /usr/lib/python3/dist-packages/ranger/colorschemes/default.py 
wget -O /usr/lib/python3/dist-packages/ranger/colorschemes/default.py https://download.al1al7.de/vim/myrangercolor.py

echo -e "#For ble.sh\n[[ \$- == *i* ]] && source /etc/custom/blesh/ble.sh --noattach --rcfile /etc/custom/blesh/blesh.conf\n\n" > $BASHFILE
cat $BASHFILEORIG >> $BASHFILE
cat bashrc_append >> $BASHFILE
rm bashrc_append
rm $BASHFILEORIG
chmod -R ugo+rx /etc/custom/blesh

