From 6d15be0a5cbc75f1be66003ce7fad840e883cf0d Mon Sep 17 00:00:00 2001 From: Joshua Finch Date: Wed, 30 Jul 2025 22:12:08 -0500 Subject: [PATCH] fix/doc: Refactoring the deploy script to actually be parameterized instead of writing out each case of config file and location. Adding some sections in the README about deployment and additions to the setup. --- README.md | 20 ++++++++++++++++- deploy.sh | 67 +++++++++++++++++++++---------------------------------- 2 files changed, 45 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 89bb356..c956dbd 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,25 @@ Included are configs for: - wezterm - zsh -While the setup is opinionated its goal is to provide desired behaviour rather than limiting to specific +## Deployment + +> [!WARNING] +> This script _WILL_ clobber existing configuration files for the above applications. Read the script and backup files before running if needed. + +Just run `./deploy.sh` + +Configurations will be deployed to standard locations for a *nix/Mac user directory by force creating a symlink back to this repository's files. + +### Additions + +Configurations and their destinations are listed in the deploy script's associative array (dict) named `configs`. Additions or alterations to locations or new configs are to be added there. + +> [!NOTE] +> The wezterm's local configuration file is not currently activated in the `configs` dict. It is meant as a local configuration file and is set up to handle some linux specific configuration settings that may not be applicable. Add this alongside the `wezterm.lua` config (uncommenting in the deploy script) and it will be automatically loaded by the main `wezterm.lua` config. + +## Updating + +`git pull` will give the latest changes and via symlinks they will immediately be available to the appropriate applications. ## Applications ### Neovim diff --git a/deploy.sh b/deploy.sh index b3e75b2..64ed668 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,46 +1,31 @@ -#Zsh -if [ ! -L $HOME/.zshrc ] -then - ln -fs $PWD/zshrc $HOME/.zshrc -fi +#!/usr/bin/env bash -if [ ! -L $HOME/.oh-my-zsh/custom/themes ] -then - ln -fs $PWD/fb-custom.zsh-theme $HOME/.oh-my-zsh/custom/themes/fb-custom.zsh-theme -fi +# Deployment script for dotfiles +# +# WARNING: This script _will_ clobber existing files by force linking -# Neovim -mkdir -p $HOME/.config/nvim -if [ ! -L $HOME/.config/nvim/init.lua ] -then - ln -fs $PWD/nvim/init.lua $HOME/.config/nvim/init.lua -fi +declare -A configs=( + ["zshrc"]="$HOME/.zshrc" + ["fb-custom.zsh-theme"]="$HOME/.oh-my-zsh/custom/themes" + ["nvim/init.lua"]="$HOME/.config/nvim/init.lua" + ["nvim/lua"]="$HOME/.config/nvim/lua" + ["nvim/snippets"]="$HOME/.config/nvim/snippets" + ["tmux.conf"]="$HOME/.tmux.conf" + ["wezterm.lua"]="$HOME/.config/wezterm/wezterm.lua" + # ["wezterm.local_linux.lua"]="$HOME/.config/wezterm/local.lua" + ["npmrc"]="$HOME/.npmrc" +) -if [ ! -L $HOME/.config/nvim/lua ] -then - ln -fs $PWD/nvim/lua $HOME/.config/nvim/lua -fi +declare -a config_directories=( + "$HOME/.config/nvim" + "$HOME/.config/wezterm" +) -if [ ! -L $HOME/.config/nvim/snippets ] -then - ln -fs $PWD/nvim/snippets $HOME/.config/nvim/snippets -fi +for dir in ${config_directories[@]}; do + mkdir -p ${dir} +done -# Tmux -if [ ! -L $HOME/.tmux.conf ] -then - ln -fs $PWD/tmux.conf $HOME/.tmux.conf -fi - -# Wezterm terminal emulator -if [ ! -L $HOME/.config/wezterm/wezterm.lua ] -then - mkdir -p $HOME/.config/wezterm - ln -fs $PWD/wezterm.lua $HOME/.config/wezterm/wezterm.lua -fi - -# Nodejs -if [ ! -L $HOME/.npmrc ] -then - ln -fs $PWD/npmrc $HOME/.npmrc -fi +for dotfile in "${!configs[@]}"; do + echo "Deploying $PWD/${dotfile} to ${configs[$dotfile]}" + ln -fs "$PWD/${dotfile}" "${configs[$dotfile]}" +done