Skip to content

Commit 0698dac

Browse files
committed
Add brew bundle cleanup to cfgmanager
1 parent 22de13c commit 0698dac

3 files changed

Lines changed: 37 additions & 24 deletions

File tree

bin/cfgmanager

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,13 @@ bootstrap() {
7373
usage() {
7474
cat <<EOS
7575
Usage: cfgmanager.sh [options]
76-
--brew-bundle Update brew, install packages, upgrade packages
77-
--create-links Create links to cofiguration files
78-
--prune-links Prune broken links
79-
--remove-links Remove all links to configuration files
80-
--bootstrap Bootstrap configuration (default)
81-
-h, --help Display this message
76+
--brew-bundle Update brew, install packages, upgrade packages
77+
--bundle-cleanup Uninstall all dependencies not present Brewfile
78+
--create-links Create links to cofiguration files
79+
--prune-links Prune broken links
80+
--remove-links Remove all links to configuration files
81+
--bootstrap Bootstrap configuration (default)
82+
-h, --help Display this message
8283
EOS
8384
}
8485

@@ -87,6 +88,10 @@ case $1 in
8788
source $DOTFILES_REPO_DIR/scripts/brew.sh
8889
brew_bundle
8990
;;
91+
--bundle-cleanup)
92+
source $DOTFILES_REPO_DIR/scripts/brew.sh
93+
bundle_cleanup
94+
;;
9095
--create-links)
9196
source $DOTFILES_REPO_DIR/scripts/links.sh
9297
create_links

home/.config/fish/conf.d/abbr.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
abbr cmbc "cfgmanager --bundle-cleanup"
12
abbr cmbb "cfgmanager --brew-bundle"
23
abbr cmcl "cfgmanager --create-links"
34
abbr cmpl "cfgmanager --prune-links"

scripts/brew.sh

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,38 @@ set -e
55
source ~/.env || { echo "Unable to source .env" && exit 1; }
66

77
if ! which brew >/dev/null; then
8-
case $(uname -sm) in
9-
"Darwin arm64")
10-
brew=/opt/homebrew/bin/brew
11-
;;
12-
*)
13-
brew=/usr/local/bin/brew
14-
;;
15-
esac
8+
case $(uname -sm) in
9+
"Darwin arm64")
10+
brew=/opt/homebrew/bin/brew
11+
;;
12+
*)
13+
brew=/usr/local/bin/brew
14+
;;
15+
esac
1616

17-
! [ -x $brew ] && echo "Unable to find brew" && exit 1
18-
eval "$($brew shellenv)"
17+
! [ -x $brew ] && echo "Unable to find brew" && exit 1
18+
eval "$($brew shellenv)"
1919
fi
2020

2121
case $CONFIG_ENV in
2222
personal)
23-
brewfile=~/.config/Brewfile
24-
;;
23+
brewfile=~/.config/Brewfile
24+
;;
2525
work)
26-
brewfile=~/.config/Brewfile_work
27-
;;
26+
brewfile=~/.config/Brewfile_work
27+
;;
2828
esac
2929

3030
brew_bundle() {
31-
echo "Running brew bundle"
32-
echo "Using brewfile: $brewfile"
33-
brew update
34-
brew bundle --file $brewfile --verbose --force --no-lock
31+
echo "Running brew bundle"
32+
echo "Using brewfile: $brewfile"
33+
brew update
34+
brew bundle --file $brewfile --verbose --force --no-lock
35+
}
36+
37+
bundle_cleanup() {
38+
echo "Running brew bundle cleanup"
39+
echo "Using brewfile: $brewfile"
40+
brew update
41+
brew bundle cleanup --file $brewfile --verbose --force --no-lock
3542
}

0 commit comments

Comments
 (0)