Skip to content

Commit

Permalink
feat: add multi select
Browse files Browse the repository at this point in the history
  • Loading branch information
gschurck committed Sep 9, 2024
1 parent 4ab4205 commit 182d354
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions fuzzybrew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,39 @@

# fuzzybrew.sh

VERSION="0.2.1"
VERSION="1.0.0"

fuzzybrew() {
local query="$1"
local selected_package
selected_package=$(
local selected_packages
selected_packages=$(
# Search all packages, evaluate all formulae, and display descriptions
brew search --eval-all --desc "" | \
# Remove the ":" in the list"
sed 's/:.*//' | \
fzf --ansi --query "$query" \
# Display the list in fzf for fuzzy search
fzf --multi --ansi --query "$query" \
--header 'Press CTRL-C to quit, ENTER to install' \
--preview 'HOMEBREW_COLOR=1 brew info {1}' \
--preview-window=right:60%:wrap
)

if [[ -n $selected_package ]]; then
echo "Running: brew install $selected_package"
brew install "$selected_package"
if [[ -n $selected_packages ]]; then
echo "Running: brew install"
# Install each selected package
echo "$selected_packages" | while read -r package; do
echo "Installing $package"
brew install "$package"
done
else
echo "No packages selected."
fi
}


if [[ "$1" == "--version" ]]; then
echo "fuzzybrew version $VERSION"
exit 0
fi

fuzzybrew "$@"
fuzzybrew "$@"

0 comments on commit 182d354

Please sign in to comment.