config/install/install-brew-extra.fish

45 lines
1.6 KiB
Fish
Executable File

#!/usr/bin/env fish
# TODO: how to handle other taps (especially an issue for casks)
function _install_extra_brews --argument-names favorite_brews
set --local brew_pkgs_installed (string collect (brew list))
set --local brew_pkgs_options
for brew_pkg in (cat $favorite_brews)
if not contains -- $brew_pkg $brew_pkgs_installed
set -a brew_pkgs_options $brew_pkg
end
end
set --local brew_pkgs_inst (string split ' ' -- $brew_pkgs_options | eval "fzf --multi --prompt='[brew:install] '")
if test (count $brew_pkgs_inst) -gt 0
echo "Installing: $brew_pkgs_inst"
brew install $brew_pkgs_inst
end
end
function _install_extra_casks --argument-names favorite_casks
set --local brew_casks_installed (string collect (brew list --cask))
set --local brew_casks_options
for brew_cask in (cat $favorite_casks)
if not contains -- $brew_cask $brew_casks_installed
set -a brew_casks_options $brew_cask
end
end
set --local brew_casks_inst (string split ' ' -- $brew_casks_options | eval "fzf --multi --prompt='[brew:install] '")
if test (count $brew_casks_inst) -gt 0
echo "Installing: $brew_casks_inst"
brew cask install $brew_casks_inst
end
end
set --local script_dir (dirname (status -f))
if contains -- '--casks' $argv
_install_extra_casks (string join '/' -- $script_dir 'homebrew-casks.txt')
else
_install_extra_brews (string join '/' -- $script_dir 'homebrew-formulas.txt')
end
functions --erase _install_extra_brews
functions --erase _install_extra_casks