dotfiles/initialize_script

51 lines
1.5 KiB
Bash
Executable file

#!/bin/bash
# Setup script for vim & tmux
if [ $EUID != 0 ]; then
echo "This script needs sudo priveleges in order to install Curl"
echo "Exiting..."
exit 1
fi
function get_path {
# Get the full path of a file
SCRIPT=`realpath $0`
# Remove everything but the filename
SCRIPTPATH=`dirname $SCRIPT`
}
function user_config {
CURL='dpkg-query -l | grep curl | wc -l'
if [ "$CURL" > 0 ]; then
echo 'Curl not installed, installing....'
apt-get install -y curl
fi
read -p 'Install the script for a normal user or root account? [user/root]: ' USER
if [[ "$USER" == "user" ]]; then
curl -fLo /home/$SUDO_USER/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
get_path
ln -s $SCRIPTPATH/vim/{.vimrc,.tmux.conf} /home/$SUDO_USER/;
ln -s $SCRIPTPATH/vim/colors /home/$SUDO_USER/.vim/
chown -R $SUDO_USER:$SUDO_USER /home/$SUDO_USER/.vim
echo 'Linking configuration files done'
elif [[ "$USER" == "root" ]]; then
curl -fLo /root/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
get_path
ln -s $SCRIPTPATH/vim/{.vimrc,.tmux.conf} /root/
ln -s $SCRIPTPATH/vim/colors /root/.vim/
echo 'Linking configuration files done'
else
echo 'No selection was made'
exit 1
fi
}
user_config
echo 'Dont forget to run :PlugInstall inside vim!'