Skip to content

Commit

Permalink
feat: Remove mackup dependency (#44)
Browse files Browse the repository at this point in the history
- use more straightforward logic for bootstrapping and unboostrapping
- mackup is broken and there are no signs of a fix
- see: lra/mackup#1924 lra/mackup#2035

## Summary by Sourcery

Remove the mackup dependency and implement custom logic for managing
dotfiles and application settings using new functions 'dotlink' and
'dotunlink'. Update scripts to use rsync for copying files and managing
symbolic links.

New Features:
- Introduce new functions 'dotlink' and 'dotunlink' for managing
symbolic links in the home directory.

Enhancements:
- Replace mackup dependency with custom logic for managing dotfiles and
application settings.
  • Loading branch information
martimlobao authored Nov 4, 2024
1 parent b048747 commit ed3368c
Show file tree
Hide file tree
Showing 27 changed files with 24 additions and 74 deletions.
1 change: 0 additions & 1 deletion apps.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ ffmpeg = "formula" # Play, record, convert, and stream audio and video
httpie = "formula" # User-friendly cURL replacement (command-line HTTP client)
imagemagick = "formula" # Tools and libraries to manipulate images in many formats
jq = "formula" # Lightweight and flexible command-line JSON processor
mackup = "formula" # Keep your Mac's application settings in sync
nano = "formula" # Free (GNU) replacement for the Pico text editor
nnn = "formula" # Tiny, lightning fast, feature-packed file manager
pandoc = "formula" # Swiss-army knife of markup format conversion
Expand Down
37 changes: 20 additions & 17 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
#!/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;

git pull origin main;
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
}

# Sync dotfiles (excludes folders, .sh files, .md files, and git files)
function bootstrap() {
rsync --exclude "*.sh" \
--exclude "*.md" \
--exclude ".DS_Store" \
--exclude ".gitignore" \
-f"- */" \
-avh --no-perms . ~;
# shellcheck source=/dev/null
source "$HOME"/.zprofile;
function dotunlink() {
rsync -av --exclude='.DS_Store' linkme/ "$HOME" | \
grep -v "building file list ... done" | \
awk '/^$/ { exit } !/\/$/ { print "Restored " $0 }'
}

if [ "$1" == "--force" ] || [ "$1" == "-f" ]; then
bootstrap;
if [ "$1" == "unlink" ]; then
dotunlink;
elif [ "$1" == "--force" ] || [ "$1" == "-f" ]; then
dotlink;
else
read -rp "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1;
echo "";
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
bootstrap;
dotlink;
fi;
fi;
unset bootstrap;

# shellcheck source=/dev/null
source "$HOME"/.zprofile
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ git config --file="$HOME"/.gitconfig.private user.email "$(op read "op://Private
git config --file="$HOME"/.gitconfig.private user.signingKey "$(op read "op://Private/Github SSH Commit Signing Key/public key")"
git config --file="$HOME"/.gitconfig.private github.user "$(op read "op://Private/Github/username")"

# Copy all files from manual/ to ~/
read -rp $'\e[1;31mDo you want to copy and overwrite all files from manual/ to $HOME? (y/n)\e[0m ' COPYMANUAL
if [[ $COPYMANUAL =~ ^[Yy]$ ]]; then
cp -r manual/ ~/
# Copy all files from copyme/ to $HOME
read -rp $'\e[1;31mDo you want to copy and overwrite all files from copyme/ to $HOME? (y/n)\e[0m ' COPYME
if [[ $COPYME =~ ^[Yy]$ ]]; then
rsync -av --exclude='.DS_Store' copyme/ "$HOME"
fi

# iStat Menus
Expand Down
15 changes: 0 additions & 15 deletions mackup/.mackup.cfg

This file was deleted.

5 changes: 0 additions & 5 deletions mackup/.mackup/aws.cfg

This file was deleted.

7 changes: 0 additions & 7 deletions mackup/.mackup/dotfiles.cfg

This file was deleted.

11 changes: 0 additions & 11 deletions mackup/.mackup/git.cfg

This file was deleted.

5 changes: 0 additions & 5 deletions mackup/.mackup/ruff.cfg

This file was deleted.

9 changes: 0 additions & 9 deletions mackup/.mackup/ssh.cfg

This file was deleted.

0 comments on commit ed3368c

Please sign in to comment.