2012-11-09 20:44:06 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-01-04 15:35:36 -08:00
|
|
|
################################################################################
|
2022-05-11 08:02:53 -07:00
|
|
|
#Copyright (C) 2022 Tony Grosinger. All rights reserved.
|
2014-01-04 15:35:36 -08:00
|
|
|
#
|
|
|
|
#Description:
|
|
|
|
# This script can be run in two modes depending on the file structure of the
|
|
|
|
# current working directory or the arguments passed to it.
|
2014-04-06 15:36:31 -07:00
|
|
|
#
|
2014-01-04 15:35:36 -08:00
|
|
|
# Mode 1: From within a cloned repository or downloaded snapshot with all files
|
|
|
|
# already present and ready to be symlinked
|
|
|
|
#
|
2014-04-06 15:36:31 -07:00
|
|
|
# Mode 2: Standalone or through Curl in which case all required files will be
|
2014-01-04 15:35:36 -08:00
|
|
|
# downloaded automatically to `~/.dotfiles` before creating symlinks.
|
|
|
|
#
|
|
|
|
################################################################################
|
2014-01-13 09:23:44 -08:00
|
|
|
|
|
|
|
DOTFILES_DIR="${HOME}/.dotfiles"
|
|
|
|
GIT_REPO_BASE="https://github.com/tgrosinger/dotfiles"
|
|
|
|
GIT_REPO="${GIT_REPO_BASE}.git"
|
2014-01-13 09:44:54 -08:00
|
|
|
REPO_TAR="${GIT_REPO_BASE}/archive/master.tar.gz"
|
2012-11-09 20:44:06 -08:00
|
|
|
|
2014-01-04 15:35:36 -08:00
|
|
|
################################################################################
|
|
|
|
# Define functions
|
|
|
|
################################################################################
|
2012-11-09 20:44:06 -08:00
|
|
|
|
2022-05-11 08:02:53 -07:00
|
|
|
# Remove a file if it exists then create a symlink to the one contained in ${DOTFILES_DIR}
|
2013-03-21 20:56:52 -07:00
|
|
|
function linkFile() {
|
2022-05-11 08:02:53 -07:00
|
|
|
ln -fns ${DOTFILES_DIR}/$1 $1;
|
2013-03-21 20:56:52 -07:00
|
|
|
}
|
|
|
|
|
2014-01-03 13:37:43 -08:00
|
|
|
# Create a directory named by first parameter. Delete directory first if it already exists.
|
2013-03-21 20:56:52 -07:00
|
|
|
function createDirectory() {
|
2014-01-03 13:37:43 -08:00
|
|
|
if [ -d $1 ]; then rm -rf $1; fi
|
2013-03-21 20:56:52 -07:00
|
|
|
mkdir $1
|
|
|
|
}
|
|
|
|
|
2014-04-06 15:36:31 -07:00
|
|
|
# Perform the actual work of copying files and creating symlinks.
|
2014-01-04 15:35:36 -08:00
|
|
|
# Requires a home directory argument.
|
|
|
|
function performSetup() {
|
2014-04-06 15:36:31 -07:00
|
|
|
if [ ${#} != 1 ]; then
|
2014-01-04 15:35:36 -08:00
|
|
|
echo "Must pass home directory to ${FUNCNAME}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
home=${1}
|
|
|
|
|
2014-01-04 16:08:11 -08:00
|
|
|
echo "Moving to Home directory..."
|
|
|
|
pushd ${home} > /dev/null
|
2014-01-04 15:35:36 -08:00
|
|
|
|
2014-01-04 16:08:11 -08:00
|
|
|
echo "Linking shell configs..."
|
2014-01-04 15:35:36 -08:00
|
|
|
linkFile ".bashrc"
|
2020-05-12 13:31:53 -07:00
|
|
|
|
2020-05-12 13:53:09 -07:00
|
|
|
echo "Linking vim..."
|
|
|
|
linkFile ".vim"
|
|
|
|
linkFile ".vimrc"
|
2020-02-03 09:27:15 -08:00
|
|
|
|
2014-01-04 16:08:11 -08:00
|
|
|
echo "Linking Git..."
|
2014-01-04 15:35:36 -08:00
|
|
|
linkFile ".gitconfig"
|
2020-11-04 09:45:58 -08:00
|
|
|
linkFile ".gitattributes"
|
2014-10-21 08:58:34 -07:00
|
|
|
|
2023-07-23 15:02:24 -07:00
|
|
|
echo "Linking LazyGit..."
|
|
|
|
mkdir -p ~/.config/lazygit
|
|
|
|
ln -fns ${DOTFILES_DIR}/.lazygit ~/.config/lazygit/config.yml
|
|
|
|
|
2024-07-13 13:13:58 -07:00
|
|
|
echo "Linking Atuin..."
|
|
|
|
mkdir -p ~/.config/atuin
|
|
|
|
ln -fns ${DOTFILES_DIR}/atuin.toml ~/.config/atuin/config.toml
|
|
|
|
|
2024-07-26 08:35:58 -07:00
|
|
|
echo "Linking Ble.sh..."
|
|
|
|
linkFile ".blerc"
|
|
|
|
|
2014-01-04 16:08:11 -08:00
|
|
|
echo "Linking tmux..."
|
2014-01-04 15:35:36 -08:00
|
|
|
linkFile ".tmux.conf"
|
|
|
|
|
|
|
|
echo "Linking inputrc..."
|
|
|
|
linkFile ".inputrc"
|
2014-10-21 08:58:34 -07:00
|
|
|
|
2019-10-01 17:19:11 -07:00
|
|
|
echo "Installing tmux plugins"
|
|
|
|
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
|
|
|
|
2024-05-30 20:57:20 -07:00
|
|
|
echo "Linking gitmux..."
|
|
|
|
linkFile ".gitmux.conf"
|
|
|
|
|
2024-05-28 19:52:49 -07:00
|
|
|
echo "Linking neovim config"
|
|
|
|
ln -fns ${DOTFILES_DIR}/nvim ~/.config/nvim
|
|
|
|
|
2024-06-04 20:51:09 -07:00
|
|
|
echo "Installing homebrew"
|
|
|
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
|
|
|
|
2020-05-12 13:31:53 -07:00
|
|
|
if [[ "${OSTYPE}" == "darwin"* ]]; then
|
2024-06-04 20:51:09 -07:00
|
|
|
brew install tmux
|
2023-07-23 14:36:40 -07:00
|
|
|
else
|
2024-06-04 20:51:09 -07:00
|
|
|
sudo apt install build-essential visidata
|
2020-05-12 13:31:53 -07:00
|
|
|
fi
|
|
|
|
|
2024-06-06 09:18:33 -07:00
|
|
|
# NOTE: Do not brew install anything with a dependency on node.
|
|
|
|
# Instead, install with npm -g.
|
|
|
|
|
2024-06-04 20:51:09 -07:00
|
|
|
brew install \
|
|
|
|
gcc \
|
|
|
|
tmux neovim \
|
|
|
|
eza bat fzf ripgrep fd jq gron \
|
2024-07-13 12:58:23 -07:00
|
|
|
hadolint \
|
2024-06-04 20:51:09 -07:00
|
|
|
git lazygit git-delta \
|
2024-06-06 09:18:33 -07:00
|
|
|
crane dive \
|
2024-06-04 20:51:09 -07:00
|
|
|
go sqlite \
|
2024-10-17 12:02:16 -07:00
|
|
|
stripe-cli restic \
|
|
|
|
deno
|
2024-06-04 20:51:09 -07:00
|
|
|
|
2024-06-06 09:18:33 -07:00
|
|
|
npm install -g @devcontainers/cli
|
2024-07-13 12:58:23 -07:00
|
|
|
npm install -g mjml
|
|
|
|
npm install -g jsonlint
|
2024-06-06 09:18:33 -07:00
|
|
|
|
2014-01-04 16:08:11 -08:00
|
|
|
popd > /dev/null
|
2014-01-04 15:35:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Initialize (Determine mode)
|
|
|
|
################################################################################
|
|
|
|
|
2022-05-11 08:02:53 -07:00
|
|
|
# Determine which mode we are running in. (Does the install script exist in the dotfiles directory?)
|
|
|
|
if [ -f ${DOTFILES_DIR}/install.sh ]; then
|
2014-01-04 15:35:36 -08:00
|
|
|
echo "Running in Mode 1: Already cloned repository"
|
2022-09-21 14:53:58 -07:00
|
|
|
performSetup ${HOME}
|
|
|
|
echo "Done! Restart your shell to see changes"
|
2014-01-04 15:35:36 -08:00
|
|
|
else
|
|
|
|
echo "Running in Mode 2: Direct from Curl"
|
|
|
|
|
|
|
|
# Make sure git is installed. Exit if it isn't.
|
2014-01-13 09:23:44 -08:00
|
|
|
if which git; then
|
|
|
|
# Git is installed, clone the repository using read-only url
|
|
|
|
if [ -d ${DOTFILES_DIR} ]; then
|
|
|
|
if [ -d ${DOTFILES_DIR}/.git ]; then
|
|
|
|
echo "Updating dotfiles repository in ${DOTFILES_DIR}"
|
|
|
|
pushd ${DOTFILES_DIR} > /dev/null
|
|
|
|
git pull > /dev/null
|
|
|
|
popd > /dev/null
|
|
|
|
else
|
|
|
|
echo "Cloning dotfiles repository to ${DOTFILES_DIR}"
|
|
|
|
rm -rf ${DOTFILES_DIR}
|
|
|
|
git clone ${GIT_REPO} ${DOTFILES_DIR}
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Cloning dotfiles repository to ${DOTFILES_DIR}"
|
|
|
|
git clone ${GIT_REPO} ${DOTFILES_DIR}
|
|
|
|
fi
|
2014-01-04 15:50:07 -08:00
|
|
|
else
|
2014-01-13 09:23:44 -08:00
|
|
|
# Git is not installed, download the zip and extract
|
2014-01-16 13:18:56 -08:00
|
|
|
if ! which wget; then
|
|
|
|
echo "You must have either git or wget installed. Please install one before continuing."
|
2014-01-13 09:23:44 -08:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d ${DOTFILES_DIR} ]; then
|
|
|
|
rm -rf ${DOTFILES_DIR}
|
|
|
|
fi
|
|
|
|
|
2014-01-13 09:44:54 -08:00
|
|
|
mkdir ${DOTFILES_DIR}
|
|
|
|
curl -L ${REPO_TAR} | tar zx --strip 1 --directory ${DOTFILES_DIR}
|
2014-01-04 15:50:07 -08:00
|
|
|
fi
|
2015-10-12 13:58:31 -07:00
|
|
|
|
2014-01-04 15:50:07 -08:00
|
|
|
performSetup ${HOME}
|
|
|
|
echo "Done! Restart your shell to see changes"
|
2014-01-04 15:35:36 -08:00
|
|
|
fi
|