qash/install.sh

48 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
read -p "Do you want to install Qash? This will move your old .bashrc and replace it with Qash. y/N "
if [[ $REPLY == 'y' ]]; then
dir=~/qash
if [[ $# -gt 1 ]]; then
dir=$1
fi
echo "Installing Qash in $dir..."
echo "Copying files..."
if [[ -d $dir ]]; then
read -p "$dir already exists. Proceed to remove it including all of its contents? y/N "
if [[ $REPLY == 'y' ]]; then
rm -rf $dir
else
echo "Installation cancelled."
exit 1
fi
fi
mkdir -p "$dir/hooks"
cp -r ./library/* $dir
cp -r ./library/hooks/* $dir/hooks/
chmod 744 -R $dir/
echo "Backing up old .bashrc..."
i=0
while [[ -f ~/.bashrc.bak.$i ]]
do
i=$((i + 1))
done;
mv ~/.bashrc ~/.bashrc.bak.$i
source $dir/load.sh
echo "#!/bin/bash" >> ~/.bashrc
echo "# Qash $QASH_VERSION" >> ~/.bashrc
echo "# Installed on $(date -u +'%02d.%02m.%Y %02H:%02M:%02S')" >> ~/.bashrc
echo "" >> ~/.bashrc
echo "source $QASH_LIBRARY_DIR/load.sh" >> ~/.bashrc
printf "\e[35mQash $QASH_VERSION successfully installed!\e[0m\n"
echo "USE source ~/.bashrc TO LOAD QASH IF YOU HAVE EXECUTED THIS SCRIPT IN ITS OWN SHELL."
exit 1
fi
echo "Installation cancelled."
exit 1