brew: make it easier to install optional tools

This commit is contained in:
Charles Gould 2020-04-09 02:20:27 -05:00
parent c9fb06d4a7
commit 8a1bd822f8
2 changed files with 45 additions and 1 deletions

View File

@ -7,5 +7,5 @@ My personal configuration files.
1. Clone this repository into `~/dotfiles`
2. Install [Homebrew](https://brew.sh/): `./install-brew.sh`
3. Install tools: `brew bundle install --file=brew/Brewfile`
4. (Optional) Install more tools: `brew bundle install --file=brew/opt/Brewfile`
4. Install optional tools: `brew/install-extra.sh [--casks]`
5. Install everything else, including symlinks: `./install.sh`

44
brew/install-extra.fish Executable file
View File

@ -0,0 +1,44 @@
#!/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 --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 cask list))
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 --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 'casks.txt')
else
_install_extra_brews (string join '/' -- $script_dir 'brews.txt')
end
functions --erase _install_extra_brews
functions --erase _install_extra_casks