dotfiles/install.sh

159 lines
6.1 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
2021-12-14 17:14:16 +00:00
GIT_REPO="https://c0de.dev/c0de/dotfiles.git"
2021-01-12 04:13:00 +00:00
DOTFILES=${HOME}/dotfiles
2021-01-13 00:33:49 +00:00
DF_HOME=${DOTFILES}/home
DF_CONFIG=${DF_HOME}/.config
2021-01-12 04:13:00 +00:00
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
2021-01-12 20:28:05 +00:00
if [ -e "${dest}" ]; then
if [ -L "${dest}" ]; then
# Already symlinked -- I'll assume correctly.
return
else
# Rename files with a ".old" extension.
2021-01-12 20:28:05 +00:00
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
2021-01-12 20:28:05 +00:00
mv -v "${dest}" "${backup}"
fi
fi
2021-01-12 20:28:05 +00:00
echo "Linking $(basename "${src}")..."
ln -sf "${src}" "${dest}"
}
2017-06-22 17:21:58 +00:00
2021-01-12 20:18:33 +00:00
read -p "Press enter to install 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
2021-01-13 00:33:49 +00:00
source "${DF_HOME}/.environment"
env _DOTFILES="${DOTFILES}" DISABLE_UPDATE_PROMPT=false zsh -f "${DOTFILES}/check_for_upgrade.sh"
else
2021-01-12 20:18:33 +00:00
echo "Cloning to ${DOTFILES}"
2021-01-12 04:13:00 +00:00
rm -rf "${DOTFILES}"
2021-01-12 04:32:06 +00:00
git clone --recurse-submodules -j$(nproc) "${GIT_REPO}" "${DOTFILES}"
fi
2021-01-12 04:13:00 +00:00
echo "Installing user binary directory to ~/bin"
2021-01-13 00:33:49 +00:00
symlink "${DF_HOME}/bin" "${HOME}/bin"
2021-01-12 04:13:00 +00:00
2021-01-17 23:52:04 +00:00
echo "Creating needed directories"
mkdir -p "${HOME}/.tmux"
mkdir -p "${HOME}/.vim/{autoload,bundle}"
2021-01-18 00:44:15 +00:00
mkdir -p "${HOME}/dev"
2021-01-17 23:52:04 +00:00
2021-01-12 04:13:00 +00:00
echo "Linking Configuration files..."
# All the dotfiles that live in the home dir directly
2021-01-14 15:56:55 +00:00
symlink "${DOTFILES}/.editorconfig" "${HOME}/.editorconfig"
symlink "${DF_HOME}/.aliases" "${HOME}/.aliases"
symlink "${DF_HOME}/.bashrc" "${HOME}/.bashrc"
symlink "${DF_HOME}/.dmrc" "${HOME}/.dmrc"
symlink "${DF_HOME}/.environment" "${HOME}/.environment"
symlink "${DF_HOME}/.functions" "${HOME}/.functions"
symlink "${DF_HOME}/.gitconfig" "${HOME}/.gitconfig"
2021-01-18 00:40:56 +00:00
symlink "${DF_HOME}/.gtkrc.mine" "${HOME}/.gtkrc.mine"
2021-02-19 22:25:26 +00:00
symlink "${DF_HOME}/.gtkrc-2.0" "${HOME}/.gtkrc-2.0"
2021-01-14 15:56:55 +00:00
symlink "${DF_HOME}/.tmux.conf" "${HOME}/.tmux.conf"
symlink "${DF_HOME}/.vimrc" "${HOME}/.vimrc"
symlink "${DF_HOME}/.zshrc" "${HOME}/.zshrc"
2021-01-12 04:13:00 +00:00
# Install ~/.config stuff
2021-01-18 00:12:33 +00:00
symlink "${DF_CONFIG}/rofi" "${HOME}/.config/rofi"
2021-01-14 15:56:55 +00:00
symlink "${DF_CONFIG}/compton" "${HOME}/.config/compton"
symlink "${DF_CONFIG}/dunst" "${HOME}/.config/dunst"
symlink "${DF_CONFIG}/gtk-2.0" "${HOME}/.config/gtk-2.0"
symlink "${DF_CONFIG}/gtk-3.0" "${HOME}/.config/gtk-3.0"
symlink "${DF_CONFIG}/htop" "${HOME}/.config/htop"
symlink "${DF_CONFIG}/i3" "${HOME}/.config/i3"
symlink "${DF_CONFIG}/morc_menu" "${HOME}/.config/morc_menu"
symlink "${DF_CONFIG}/nitrogen" "${HOME}/.config/nitrogen"
symlink "${DF_CONFIG}/terminator" "${HOME}/.config/terminator"
symlink "${DF_CONFIG}/ranger" "${HOME}/.config/ranger"
symlink "${DF_CONFIG}/viewnior" "${HOME}/.config/viewnior"
symlink "${DF_CONFIG}/mimeapps.list" "${HOME}/.config/mimeapps.list"
symlink "${DF_CONFIG}/Code/User/settings.json" "${HOME}/.config/Code/User/settings.json"
2017-06-22 17:21:58 +00:00
2022-08-17 21:41:31 +00:00
echo "Installing Nord rofi theme"
2022-08-17 21:43:43 +00:00
wget https://raw.githubusercontent.com/undiabler/nord-rofi-theme/master/nord.rasi -O "${HOME}/.config/rofi/themes/nord.rasi"
2022-08-17 21:41:31 +00:00
echo "Installing Iceberg Icon pack..."
# symlink "${DF_HOME}/.themes/oomox-iceberg" "${HOME}/.themes/oomox-iceberg"
2021-01-17 23:53:41 +00:00
symlink "${DF_HOME}/.icons/oomox-iceberg" "${HOME}/.icons/oomox-iceberg"
2021-01-14 16:54:59 +00:00
echo "Installing Nord GTK theme"
mkdir -p "${HOME}/.themes/Nordic"
wget https://github.com/EliverLara/Nordic/releases/download/v2.2.0/Nordic.tar.xz -O "${HOME}/.themes/Nordic.tar.xz"
tar -xf "${HOME}/.themes/Nordic.tar.xz" -C "${HOME}/.themes/Nordic"
2021-01-12 20:18:33 +00:00
echo "Building i3 configuration..."
2021-01-13 00:33:49 +00:00
"${DF_HOME}/bin/build-i3-config"
2021-01-12 20:18:33 +00:00
echo "Changing default shell to ZSH..."
chsh -s /usr/bin/zsh
echo "Installing Oh-My-ZSH..."
CHSH='no' RUNZSH='no' KEEP_ZSHRC='yes' sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
2021-01-17 23:48:46 +00:00
#echo "Installing VSCode Extensions..."
#cat "${DOTFILES}/vs_code_extensions.lst" | xargs -n 1 code --install-extension --force
echo "Installing VIM Pathogen..."
2021-01-12 20:07:00 +00:00
curl -LSs https://tpo.pe/pathogen.vim -o "${HOME}/.vim/autoload/pathogen.vim"
2017-06-22 17:21:58 +00:00
2022-08-17 21:51:04 +00:00
echo "Installing VIM Plug"
curl -fLo "${HOME}/.vim/autoload/plug.vim" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
echo "Installing VIM Sensible..."
2021-01-12 20:07: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
2021-03-31 17:57:00 +00:00
echo "Installing VIM Better Whitespace..."
git clone https://github.com/ntpeters/vim-better-whitespace.git "${HOME}/.vim/bundle/vim-better-whitespace"
echo "Installing VIM Indent Guides..."
git clone https://github.com/thaerkh/vim-indentguides.git "${HOME}/.vim/bundle/vim-indentguides"
2021-01-12 20:18:33 +00:00
echo "Installing VIM Iceberg theme..."
2020-10-05 15:30:49 +00:00
cd /tmp
wget https://www.vim.org/scripts/download_script.php?src_id=25718 -O iceberg.zip
unzip iceberg.zip
2021-01-12 20:07:00 +00:00
cp -r iceberg.vim/{autoload,colors} "${HOME}/.vim/"
2021-01-12 04:13:00 +00:00
rm -rf /tmp/iceberg*
2021-01-12 20:07:00 +00:00
cd "${HOME}"
2020-10-05 15:30:49 +00:00
2021-01-12 20:07:00 +00:00
if [ -e "${POSTINSTALL_SCRIPT}" ]; then
echo "Running post install..."
2021-01-12 20:07:00 +00:00
"${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