prevent saving a package to brewfile more than once

This commit is contained in:
Sloane Perrault 2022-08-06 08:33:27 -04:00
parent 6c8ad31e63
commit 0dcaf34739

View file

@ -6,10 +6,16 @@ function brew-save -d "Install a new homebrew cask and update the global Brewfil
else
set -f brewfile_keyword brew
end
echo "$brewfile_keyword \"$package\"" >> ~/.Brewfile
brew bundle --global
set -l brewfile_line "$brewfile_keyword \"$package\""
if grep $brewfile_line ~/.Brewfile &> /dev/null
echo "package already in ~/.Brewfile: $package"
return 1
else
echo "$brewfile_keyword \"$package\"" >> ~/.Brewfile
brew bundle --global
end
else
echo "package not found: $argv"
echo "package not found: $package"
return 1
end
end