Files
battery/update.sh
2022-12-12 11:54:33 +01:00

31 lines
763 B
Bash

#!/bin/bash
# Force-set path to include sbin
PATH="$PATH:/usr/sbin"
# Set environment variables
tempfolder=~/.battery-tmp
binfolder=/usr/local/bin
batteryfolder="$tempfolder/battery"
mkdir -p $batteryfolder
echo -e "🔋 Starting battery update\n"
# Write battery function as executable
echo "[ 1/3 ] Cloning battery repository"
rm -rf $batteryfolder
git clone --depth 1 https://github.com/actuallymentor/battery.git $batteryfolder &> /dev/null
echo "[ 2/3 ] Writing script to $binfolder/battery"
cp $batteryfolder/battery.sh $binfolder/battery
chown $USER $binfolder/battery
chmod 755 $binfolder/battery
chmod u+x $binfolder/battery
# Remove tempfiles
cd
rm -rf $tempfolder
echo "[ 3/3 ] Removed temporary folder"
echo -e "\n🎉 Battery tool updated.\n"