-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Fix bootstrap script and general improvements (#45)
- proper bootstrap script - rename setup.sh to run.sh and clean up - remove need for sudo in local.sh - move computer rename to macos.sh - create dotsync.sh - disable auto-run for macos.sh (needs fixing) - update readme and license - general cleanup ## Summary by Sourcery Revamp the bootstrap process by introducing a new 'dotsync.sh' script for dotfile management, renaming 'setup.sh' to 'run.sh', and removing 'sudo' requirements from 'local.sh'. Update the README and LICENSE to reflect these changes and improve script idempotency and security by integrating 1Password for secret management. New Features: - Introduce a new script 'dotsync.sh' for managing dotfiles linking and unlinking. Enhancements: - Rename 'setup.sh' to 'run.sh' and streamline its functionality. - Remove the need for 'sudo' in 'local.sh' to enhance security and usability. - Move computer renaming functionality from 'local.sh' to 'macos.sh'. - Make scripts idempotent, allowing them to be run multiple times without issues. - Add support for 1Password to manage secrets used by scripts. Documentation: - Update README.md to reflect changes in script names and usage instructions. - Revise LICENSE.md to update copyright years. --------- Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
- Loading branch information
1 parent
ed3368c
commit cc8340c
Showing
10 changed files
with
239 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Source the bash_traceback.sh file | ||
source "$(dirname "$0")/bash_traceback.sh" | ||
|
||
############################################################################### | ||
# UPDATE DOTFILES # | ||
############################################################################### | ||
|
||
cd "$(dirname "${BASH_SOURCE:-$0}")" || exit 1; | ||
|
||
function dotlink() { | ||
find "linkme" -type d -mindepth 1 | sed "s|^linkme/||" | while read -r dir; do mkdir -p "$HOME/$dir"; done | ||
find "linkme" -type f -not -name '.DS_Store' | sed "s|^linkme/||" | while read -r file; do ln -fvns "$(pwd)/linkme/$file" "$HOME/$file"; done | ||
} | ||
|
||
function dotunlink() { | ||
rsync -av --exclude='.DS_Store' linkme/ "$HOME" | \ | ||
grep -v "building file list ... done" | \ | ||
awk '/^$/ { exit } !/\/$/ { print "Restored " $0 }' | ||
} | ||
|
||
if [ "$1" == "unlink" ]; then | ||
dotunlink; | ||
elif [ "$1" == "--force" ] || [ "$1" == "-f" ]; then | ||
dotlink; | ||
{ # Prevent script from running if partially downloaded | ||
|
||
set -euo pipefail | ||
|
||
DOTPATH=$HOME/.dotfiles | ||
|
||
echo -e "\033[1;34mπ₯Ύ Bootstrapping dotfiles\033[0m" | ||
|
||
if [ ! -d "$DOTPATH" ]; then | ||
git clone https://github.com/martimlobao/dotfiles.git "$DOTPATH" | ||
echo -e "\033[1;32mβ Cloned $DOTPATH\033[0m" | ||
else | ||
read -rp $'β \e[1;31mThis may overwrite existing files in your home directory. Are you sure? (y/n)\e[0m ' REPLY | ||
if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
dotlink; | ||
fi; | ||
fi; | ||
|
||
# shellcheck source=/dev/null | ||
source "$HOME"/.zprofile | ||
echo -e "\033[1;34mβ Dotfiles already downloaded to $DOTPATH\033[0m" | ||
fi | ||
|
||
cd "$DOTPATH" | ||
|
||
if [[ "${1:-}" == "--yes" ]] || [[ "${1:-}" == "-y" ]]; then | ||
./run.sh -y | ||
else | ||
./run.sh | ||
fi | ||
|
||
} # Prevent script from running if partially downloaded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Source the bash_traceback.sh file | ||
source "$(dirname "$0")/bash_traceback.sh" | ||
|
||
############################################################################### | ||
# UPDATE DOTFILES # | ||
############################################################################### | ||
|
||
# echo -e "\033[1;34mπ Installing dotfiles...\033[0m" | ||
# sleep 1 | ||
|
||
function dotlink() { | ||
find "linkme" -type d -mindepth 1 | sed "s|^linkme/||" | \ | ||
while read -r dir; do mkdir -p "$HOME/$dir"; done | ||
find "linkme" -type f -not -name '.DS_Store' | sed "s|^linkme/||" | \ | ||
while read -r file; do | ||
echo -e "\033[1;32mπ Linked $(pwd)/linkme/$file -> $HOME/$file\033[0m" | ||
ln -fvns "$(pwd)/linkme/$file" "$HOME/$file" &> /dev/null; | ||
done | ||
} | ||
|
||
function dotunlink() { | ||
rsync -av --exclude='.DS_Store' linkme/ "$HOME" | \ | ||
grep -v "building file list ... done" | \ | ||
awk '/^$/ { exit } !/\/$/ { printf "\033[1;32mπ Restored %s\033[0m\n", $0; }' | ||
} | ||
|
||
# Copy all files from copyme/ to $HOME | ||
if [ "${1:-}" == "unlink" ]; then | ||
echo -e "\033[1;34mπ Restoring dotfiles...\033[0m" | ||
dotunlink; | ||
else | ||
echo -e "\033[1;34mπ Linking dotfiles...\033[0m" | ||
if [[ "${1:-}" != "-y" ]] && [[ "${1:-}" != "--yes" ]]; then | ||
read -rp $'β \e[1;31mOverwrite existing dotfiles with symlinks to stored dotfiles? (y/n)\e[0m ' LINK | ||
else | ||
LINK="y" | ||
fi | ||
|
||
if [[ $LINK =~ ^[Yy]$ ]]; then | ||
dotlink; | ||
fi | ||
fi | ||
|
||
# shellcheck source=/dev/null | ||
source "$HOME"/.zprofile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.