dotfiles/install.sh

112 lines
3.2 KiB
Bash
Raw Normal View History

#!/bin/bash
# Adrien Luxey - Feb. 2019
# Script inspired by https://github.com/mathiasbynens/dotfiles/blob/master/bootstrap.sh
2019-02-08 10:36:41 +00:00
# Get dotfiles dir
DOTDIR=$(cd "$(dirname ${BASH_SOURCE})"; pwd)
2019-02-08 10:36:41 +00:00
INSTALLED_FLAG_FILE="$DOTDIR/.installed"
INSTALL_SUBLIME=0
function printHelp {
cat <<-EOF
USAGE: $0 [OPTIONS]
OPTIONS:
-s|--sublime Install Sublime Text 3
-h|--help Show this help
The script will install dependencies once (remove ${INSTALLED_FLAG_FILE} to redo) and symlink dotfiles to their destination in your \$HOME.
EOF
exit $1;
}
2019-02-08 10:36:41 +00:00
function syncDotfiles {
echo Removing previous dotfiles...
rm $HOME/.zshrc > /dev/null 2>&1
rm $HOME/.vimrc > /dev/null 2>&1
rm $HOME/.tmux.conf > /dev/null 2>&1
rm -rf $HOME/.vim > /dev/null 2>&1
rm -rf $HOME/.tmux > /dev/null 2>&1
rm $HOME/.ssh/config > /dev/null 2>&1
2019-02-08 10:36:41 +00:00
echo Installing our dotfiles...
ln -s $DOTDIR/zshrc $HOME/.zshrc
ln -s $DOTDIR/vimrc $HOME/.vimrc
ln -s $DOTDIR/tmux.conf $HOME/.tmux.conf
ln -s $DOTDIR/vim $HOME/.vim
ln -s $DOTDIR/tmux $HOME/.tmux
2019-02-08 10:39:22 +00:00
if [ -d "$HOME/.config/sublime-text-3" ]; then
2022-10-04 19:20:50 +00:00
rm -rf $HOME/.config/sublime-text-3/Packages/User > /dev/null 2>&1
2019-02-08 10:39:22 +00:00
ln -s $DOTDIR/sublime $HOME/.config/sublime-text-3/Packages/User
2022-10-02 16:50:51 +00:00
elif [ -d "$HOME/.config/sublime-text" ]; then
2022-10-04 19:20:50 +00:00
rm -rf $HOME/.config/sublime-text/Packages/User > /dev/null 2>&1
2022-10-02 16:50:51 +00:00
ln -s $DOTDIR/sublime $HOME/.config/sublime-text/Packages/User
2019-02-08 10:39:22 +00:00
fi
mkdir -p $HOME/.ssh
ln -s $DOTDIT/ssh_config ~/.ssh/config
}
2019-02-08 10:36:41 +00:00
function installDependencies {
echo Installing dependencies...
# Dependencies
2019-02-08 10:36:41 +00:00
sudo apt update > /dev/null 2>&1
2022-10-02 16:50:51 +00:00
sudo apt install -y apt-transport-https curl zsh tmux autojump fonts-firacode fonts-powerline > /dev/null 2>&1
# Install Sublime Text
2019-02-08 10:36:41 +00:00
if [[ ${INSTALL_SUBLIME} -eq 1 ]]; then
echo Installing Sublime Text 3...
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - > /dev/null 2>&1
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list > /dev/null 2>&1
2022-10-04 19:20:50 +00:00
#sudo apt update > /dev/null 2>&1
2019-02-08 10:36:41 +00:00
sudo apt install sublime-text -y > /dev/null 2>&1
fi
# Install Oh My Zsh
2019-02-08 10:36:41 +00:00
if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo Installing Oh-My-Zsh...
2019-02-11 13:15:39 +00:00
sh -c "$(wget -q https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
2019-02-08 10:36:41 +00:00
# Install powerlevel9k theme in Oh-My-Zsh
if [ ! -d "$HOME/.oh-my-zsh/custom/themes/powerlevel9k" ]; then
echo Installing Powerlevel9k theme...
git clone https://github.com/bhilburn/powerlevel9k.git $HOME/.oh-my-zsh/custom/themes/powerlevel9k > /dev/null 2>&1
fi
fi
2019-02-11 15:34:30 +00:00
echo "Pulling git submodules..."
2022-10-02 16:50:51 +00:00
cd $DOTDIR && (git submodule update --init >> /dev/null 2>&1) || echo "'git submobule update --init' failed, is your SSH key available on GitHub?" && exit -1;
# Make ZSH is the current SHELL
echo $SHELL | grep zsh > /dev/null || chsh -s $(which zsh)
}
2019-02-08 10:36:41 +00:00
# Parse command-line arguments
while (( "$#" )); do
case "$1" in
-h|--help)
printHelp 0
;;
-s|--sublime)
INSTALL_SUBLIME=1
shift
;;
--)
shift
break
;;
-*|--*=)
echo "Error: Unsupported flag $1" >&2
printHelp 1
;;
esac
done
if [ ! -f $INSTALLED_FLAG_FILE ]; then
installDependencies && touch $INSTALLED_FLAG_FILE
fi
syncDotfiles
echo "All done!"
2019-02-11 13:15:39 +00:00
exit 0