improved install script
This commit is contained in:
parent
9624a017a9
commit
d0e4738275
3 changed files with 74 additions and 36 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.installed
|
87
install.sh
87
install.sh
|
@ -3,12 +3,27 @@
|
||||||
# Adrien Luxey - Feb. 2019
|
# Adrien Luxey - Feb. 2019
|
||||||
# Script inspired by https://github.com/mathiasbynens/dotfiles/blob/master/bootstrap.sh
|
# Script inspired by https://github.com/mathiasbynens/dotfiles/blob/master/bootstrap.sh
|
||||||
|
|
||||||
|
# Get dotfiles dir
|
||||||
# cd to this file's directory
|
|
||||||
DOTDIR=$(cd "$(dirname ${BASH_SOURCE})"; pwd)
|
DOTDIR=$(cd "$(dirname ${BASH_SOURCE})"; pwd)
|
||||||
# echo "DOTDIR: " $DOTDIR
|
INSTALLED_FLAG_FILE="$DOTDIR/.installed"
|
||||||
|
INSTALL_SUBLIME=0
|
||||||
|
|
||||||
function syncDotfiles() {
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncDotfiles {
|
||||||
|
echo Removing previous dotfiles...
|
||||||
rm $HOME/.zshrc > /dev/null 2>&1
|
rm $HOME/.zshrc > /dev/null 2>&1
|
||||||
rm $HOME/.vimrc > /dev/null 2>&1
|
rm $HOME/.vimrc > /dev/null 2>&1
|
||||||
rm $HOME/.tmux.conf > /dev/null 2>&1
|
rm $HOME/.tmux.conf > /dev/null 2>&1
|
||||||
|
@ -16,33 +31,73 @@ function syncDotfiles() {
|
||||||
rm -rf $HOME/.tmux > /dev/null 2>&1
|
rm -rf $HOME/.tmux > /dev/null 2>&1
|
||||||
rm -rf $HOME/.config/sublime-text-3/Packages/User > /dev/null 2>&1
|
rm -rf $HOME/.config/sublime-text-3/Packages/User > /dev/null 2>&1
|
||||||
|
|
||||||
|
echo Installing our dotfiles...
|
||||||
ln -s $DOTDIR/zshrc $HOME/.zshrc
|
ln -s $DOTDIR/zshrc $HOME/.zshrc
|
||||||
ln -s $DOTDIR/vimrc $HOME/.vimrc
|
ln -s $DOTDIR/vimrc $HOME/.vimrc
|
||||||
ln -s $DOTDIR/tmux.conf $HOME/.tmux.conf
|
ln -s $DOTDIR/tmux.conf $HOME/.tmux.conf
|
||||||
ln -s $DOTDIR/vim $HOME/.vim
|
ln -s $DOTDIR/vim $HOME/.vim
|
||||||
ln -s $DOTDIR/tmux $HOME/.tmux
|
ln -s $DOTDIR/tmux $HOME/.tmux
|
||||||
ln -s $DOTDIR/sublime $HOME/.config/sublime-text-3/Packages/User
|
ln -s $DOTDIR/sublime $HOME/.config/sublime-text-3/Packages/User
|
||||||
|
|
||||||
}
|
}
|
||||||
syncDotfiles
|
|
||||||
|
|
||||||
function installDependencies() {
|
function installDependencies {
|
||||||
|
echo Installing dependencies...
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
sudo apt update
|
sudo apt update > /dev/null 2>&1
|
||||||
sudo apt install -y apt-transport-https curl zsh fonts-powerline
|
sudo apt install -y apt-transport-https curl zsh fonts-powerline > /dev/null 2>&1
|
||||||
|
|
||||||
# Install Sublime Text
|
# Install Sublime Text
|
||||||
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
|
if [[ ${INSTALL_SUBLIME} -eq 1 ]]; then
|
||||||
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
|
echo Installing Sublime Text 3...
|
||||||
sudo apt update
|
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - > /dev/null 2>&1
|
||||||
sudo apt install sublime-text -y
|
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list > /dev/null 2>&1
|
||||||
|
sudo apt update > /dev/null 2>&1
|
||||||
|
sudo apt install sublime-text -y > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
# Install Oh My Zsh
|
# Install Oh My Zsh
|
||||||
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
|
if [ ! -d "$HOME/.oh-my-zsh" ]; then
|
||||||
|
echo Installing Oh-My-Zsh...
|
||||||
|
sh -c "$(wget -q https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" > /dev/null 2>&1
|
||||||
# Install powerlevel9k theme in Oh-My-Zsh
|
# Install powerlevel9k theme in Oh-My-Zsh
|
||||||
git clone https://github.com/bhilburn/powerlevel9k.git $HOME/.oh-my-zsh/custom/themes/powerlevel9k
|
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
|
||||||
|
|
||||||
# Set ZSH as default shell
|
# Set ZSH as default shell
|
||||||
sudo -u $USER chsh -s $(which zsh)
|
if [ ! "$SHELL" = "$(which zsh)" ]; then
|
||||||
|
echo Setting ZSH as default shell...
|
||||||
|
chsh -s $(which zsh)
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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!"
|
||||||
|
exit 0
|
18
sync.sh
18
sync.sh
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Adrien Luxey - Feb. 2019
|
|
||||||
# Script inspired by https://github.com/mathiasbynens/dotfiles/blob/master/bootstrap.sh
|
|
||||||
|
|
||||||
# cd to this file's directory
|
|
||||||
cd "$(dirname "${BASH_SOURCE}")";
|
|
||||||
|
|
||||||
git pull origin master
|
|
||||||
|
|
||||||
# Get dotfiles (and dot directories) in current directory
|
|
||||||
dotfiles=$(find . -maxdepth 1 -regex "\./\..+" -printf "%f\n")
|
|
||||||
|
|
||||||
function syncDotfiles() {
|
|
||||||
ln -s $dotfiles ~
|
|
||||||
}
|
|
||||||
|
|
||||||
syncDotfiles
|
|
Loading…
Reference in a new issue