From 182d354dd0521697453ce57300198cac12ced41f Mon Sep 17 00:00:00 2001 From: Guillaume Schurck <21091232+gschurck@users.noreply.github.com> Date: Mon, 9 Sep 2024 21:09:31 +0200 Subject: [PATCH] feat: add multi select --- fuzzybrew.sh | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/fuzzybrew.sh b/fuzzybrew.sh index 3761282..65176aa 100644 --- a/fuzzybrew.sh +++ b/fuzzybrew.sh @@ -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 "$@" \ No newline at end of file +fuzzybrew "$@"