-
Notifications
You must be signed in to change notification settings - Fork 0
/
fuzzybrew.sh
executable file
·43 lines (36 loc) · 1.04 KB
/
fuzzybrew.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
# fuzzybrew.sh
VERSION="1.1.1"
fuzzybrew() {
local query="$1"
local selected_packages
selected_packages=$(
# Search all packages, evaluate all formulae, and display descriptions
brew search --eval-all --desc "" | \
# Remove lines starting with "==>"
sed -e '/^==>/d' | \
# Display the list in fzf for fuzzy search
# Search only by package name
fzf --multi --ansi --query "$query" \
--delimiter=': ' \
--nth=1 \
--header 'Press CTRL-C to quit, ENTER to install, SHIFT-TAB to select multiple' \
--preview 'HOMEBREW_COLOR=1 brew info {1}' \
--preview-window=right:50%:wrap
)
if [[ -n $selected_packages ]]; then
echo "Running: brew install"
# Install each selected package
echo "$selected_packages" | cut -f1 -d':' | 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 "$@"