diff --git a/.config/fish/functions/brew-save.fish b/.config/fish/functions/brew-save.fish index e5097c4..79cd9ad 100755 --- a/.config/fish/functions/brew-save.fish +++ b/.config/fish/functions/brew-save.fish @@ -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