dotfiles/install.sh

130 lines
4.7 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# This ensures that the entire script is downloaded before execution
{
2021-01-12 04:13:00 +00:00
if ! which git >>/dev/null ; then
echo "Error: git is not installed"
exit 1
fi
# Exit the script if any errors are encountered
2018-05-17 03:46:31 +00:00
#set -e
2021-01-12 04:13:00 +00:00
# Change this url to point to your repo if you made customizations
GIT_REPO="git://github.com/alopexc0de/dotfiles.git"
DOTFILES=${HOME}/dotfiles
POSTINSTALL_SCRIPT=${HOME}/.dotfiles.postinst
if [ ! -e "${POSTINSTALL_SCRIPT}" ]; then
echo "No post install script found."
echo "Optionally create one at ${POSTINSTALL_SCRIPT} and rerun this script"
fi
# Attempts to safely install the configs as symlinks (backing up existing ones)
function symlink() {
src=$1
dest=$2
if [ -e $dest ]; then
if [ -L $dest ]; then
# Already symlinked -- I'll assume correctly.
return
else
# Rename files with a ".old" extension.
echo "$dest already exists, renaming to $dest.old"
backup=$dest.old
if [ -e $backup ]; then
echo "Error: $backup already exists. Please delete or rename it."
exit 1
fi
mv -v $dest $backup
fi
fi
echo "Linking $(basename $src)..."
ln -sf $src $dest
}
2017-06-22 17:21:58 +00:00
2018-10-18 18:12:15 +00:00
read -p "Press enter to install my dotfiles " WAIT_FOR_INPUT
2018-05-16 22:37:00 +00:00
# If the update script exists, try to do a normal update
2021-01-12 04:13:00 +00:00
if [ -x "${DOTFILES}/check_for_upgrade.sh" ]; then
source "${DOTFILES}/.environment"
env DOTFILES=${DOTFILES} DISABLE_UPDATE_PROMPT=false zsh -f ${DOTFILES}/check_for_upgrade.sh
else
2021-01-12 04:13:00 +00:00
echo "Cloning dotfiles to ${DOTFILES}"
rm -rf "${DOTFILES}"
git clone --depth=1 --recurse-submodules -j$(nproc) "${GIT_REPO}" "${DOTFILES}"
fi
2020-10-05 15:30:49 +00:00
echo "Installing Oh-My-ZSH"
echo "When the install is done, type \"exit\" to continue installing dotfiles"
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
2021-01-12 04:13:00 +00:00
echo "Changing default shell to ZSH..."
chsh -s /usr/bin/zsh
2020-03-26 16:09:36 +00:00
2021-01-12 04:13:00 +00:00
echo "Building i3 configuration"
${DOTFILES}/bin/build-i3-config
echo "Installing user binary directory to ~/bin"
symlink ${DOTFILES}/bin ${HOME}/bin
echo "Linking Configuration files..."
# All the dotfiles that live in the home dir directly
symlink ${DOTFILES}/.aliases ${HOME}/.aliases
symlink ${DOTFILES}/.bashrc ${HOME}/.bashrc
symlink ${DOTFILES}/.dmenurc ${HOME}/.dmenurc
symlink ${DOTFILES}/.dmrc ${HOME}/.dmrc
symlink ${DOTFILES}/.editorconfig ${HOME}/.editorconfig
symlink ${DOTFILES}/.environment ${HOME}/.environment
symlink ${DOTFILES}/.functions ${HOME}/.functions
symlink ${DOTFILES}/.gitconfig ${HOME}/.gitconfig
symlink ${DOTFILES}/.stalonetrayrc ${HOME}/.stalonetrayrc
symlink ${DOTFILES}/.tmux.conf ${HOME}/.tmux.conf
symlink ${DOTFILES}/.vimrc ${HOME}/.vimrc
symlink ${DOTFILES}/.zshrc ${HOME}/.zshrc
# Install ~/.config stuff
symlink ${DOTFILES}/.config/.rofi ${HOME}/.config/.rofi
symlink ${DOTFILES}/.config/compton ${HOME}/.config/compton
symlink ${DOTFILES}/.config/dunst ${HOME}/.config/dunst
symlink ${DOTFILES}/.config/gtk-2.0 ${HOME}/.config/gtk-2.0
symlink ${DOTFILES}/.config/gtk-3.0 ${HOME}/.config/gtk-3.0
symlink ${DOTFILES}/.config/htop ${HOME}/.config/htop
symlink ${DOTFILES}/.config/i3 ${HOME}/.config/i3
symlink ${DOTFILES}/.config/morc_menu ${HOME}/.config/morc_menu
symlink ${DOTFILES}/.config/nitrogen ${HOME}/.config/nitrogen
symlink ${DOTFILES}/.config/ranger ${HOME}/.config/ranger
symlink ${DOTFILES}/.config/terminator ${HOME}/.config/terminator
symlink ${DOTFILES}/.config/viewnior ${HOME}/.config/viewnior
symlink ${DOTFILES}/.config/volumeicon ${HOME}/.config/volumeicon
symlink ${DOTFILES}/.config/mimeapps.list ${HOME}/.config/mimeapps.list
2017-06-22 17:21:58 +00:00
echo "Installing VIM Pathogen..."
2021-01-12 04:13:00 +00:00
mkdir -p ${HOME}/.vim/{autoload,bundle}
curl -LSs https://tpo.pe/pathogen.vim -o ${HOME}/.vim/autoload/pathogen.vim
2017-06-22 17:21:58 +00:00
echo "Installing VIM Sensible..."
2021-01-12 04:13:00 +00:00
git clone git://github.com/tpope/vim-sensible.git ${HOME}/.vim/bundle/vim-sensible
2017-06-22 17:21:58 +00:00
2020-10-05 15:30:49 +00:00
echo "Installing VIM Iceberg theme"
cd /tmp
wget https://www.vim.org/scripts/download_script.php?src_id=25718 -O iceberg.zip
unzip iceberg.zip
2021-01-12 04:13:00 +00:00
cp -r iceberg.vim/{autoload,colors} ${HOME}/.vim/
rm -rf /tmp/iceberg*
cd ${HOME}
2020-10-05 15:30:49 +00:00
2021-01-12 04:13:00 +00:00
if [ -e "$POSTINSTALL_SCRIPT" ]; then
echo "Running post install..."
2021-01-12 04:13:00 +00:00
source "$POSTINSTALL_SCRIPT"
fi
2017-06-22 17:21:58 +00:00
echo "Install done."
2021-01-12 03:41:00 +00:00
echo "Log out and back in again for everything to take effect."
} # Ensures that the whole script is downloaded before execution