setup_env/setup_env.sh
Paul Trowbridge fcf1132a61 add td week subcommand, nvim centralization, and README
td week parses git log for task create/complete events and joins with
time.csv for weekly "what got done" reports. Nvim integration moved into
dotfiles/nvim/ (symlinked in by new deploy_nvim step) so all three td
surfaces live under dotfiles. README covers the deploy pattern and td.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-24 17:25:06 -04:00

111 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
# Function to install packages
install_packages() {
echo "Updating package list..."
sudo apt update
echo "Installing basic packages..."
sudo apt install -y tmux vim git pspg bat fzf ripgrep
}
# Install Tmux Plugin Manager (TPM) if not already installed
install_tpm() {
if [[ ! -d ~/.tmux/plugins/tpm ]]; then
echo "Installing Tmux Plugin Manager..."
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
else
echo "Tmux Plugin Manager already installed, skipping..."
fi
}
# Install Vundle (Vim plugin manager) if not already installed
install_vundle() {
if [[ ! -d ~/.vim/bundle/Vundle.vim ]]; then
echo "Installing Vundle for Vim..."
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
else
echo "Vundle already installed, skipping..."
fi
}
# Install git-bash-prompt if not already installed
install_git_bash_prompt() {
if [[ ! -d ~/.bash-git-prompt ]]; then
echo "Installing git-bash-prompt..."
git clone https://github.com/magicmonty/bash-git-prompt.git ~/.bash-git-prompt --depth=1
else
echo "git-bash-prompt already installed, skipping..."
fi
}
# Back up and create symlink
create_symlink() {
local target=$1
local link_name=$2
if [[ -L $link_name || -f $link_name ]]; then
echo "Backing up existing $link_name to ${link_name}.backup"
mv "$link_name" "${link_name}.backup"
fi
echo "Creating symlink: $link_name -> $target"
ln -s "$target" "$link_name"
}
# Deploy configuration files as symlinks
deploy_configs() {
echo "Deploying configuration files as symlinks..."
CONFIG_DIR="$(pwd)/dotfiles" # Use the local 'dotfiles' directory in the repo
for config in .bashrc .bashrc_local .vimrc .gitconfig .pspgconf .psqlrc .tmux.conf ; do
create_symlink "$CONFIG_DIR/$config" ~/$config
done
echo "Sourcing .bashrc..."
source ~/.bashrc
}
# Deploy executable scripts from dotfiles/bin/ into ~/.local/bin/
deploy_bin() {
echo "Deploying scripts to ~/.local/bin/ ..."
local src_dir="$(pwd)/dotfiles/bin"
[[ -d "$src_dir" ]] || return 0
mkdir -p ~/.local/bin
for script in "$src_dir"/*; do
[[ -f "$script" ]] || continue
create_symlink "$script" ~/.local/bin/"$(basename "$script")"
done
}
# Deploy nvim lua modules from dotfiles/nvim/ into ~/.config/nvim/lua/
# NOTE: requires ~/.config/nvim/ to already exist (see install_neovim.sh + install_nvchad.sh).
# Modules are required by name from ~/.config/nvim/lua/mappings.lua — e.g. require("td_mappings").
deploy_nvim() {
echo "Deploying nvim lua modules to ~/.config/nvim/lua/ ..."
local src_dir="$(pwd)/dotfiles/nvim"
[[ -d "$src_dir" ]] || return 0
if [[ ! -d ~/.config/nvim/lua ]]; then
echo " ~/.config/nvim/lua missing — run install_neovim.sh + install_nvchad.sh first. Skipping."
return 0
fi
for mod in "$src_dir"/*.lua; do
[[ -f "$mod" ]] || continue
create_symlink "$mod" ~/.config/nvim/lua/"$(basename "$mod")"
done
}
# Main script
main() {
install_packages
install_tpm
install_vundle
install_git_bash_prompt
deploy_configs
deploy_bin
deploy_nvim
echo "Setup complete! Please restart your shell or run 'source ~/.bashrc' for changes to take effect."
}
main