-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathfzf-brew-uninstall
More file actions
executable file
·36 lines (29 loc) · 733 Bytes
/
Copy pathfzf-brew-uninstall
File metadata and controls
executable file
·36 lines (29 loc) · 733 Bytes
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
#!/usr/bin/env bash
#
# Original source: https://bluz71.github.io/2018/11/26/fuzzy-finding-in-bash-with-fzf.html
set -o pipefail
if [[ -n "$DEBUG" ]]; then
set -x
fi
fail() {
printf '%s\n' "$1" >&2 ## Send message to stderr. Exclude >&2 if you don't want it that way.
exit "${2-1}" ## Return a code specified by $2 or 1 by default.
}
has() {
which "$@" > /dev/null 2>&1
}
if ! has brew; then
fail "Can't find brew in your PATH"
fi
# Delete (one or multiple) selected application(s)
fzf-brew-uninstall() {
uninst=$(brew leaves | fzf -m --preview 'brew info {}')
if [[ $uninst ]]; then
for prog in $uninst
do
brew uninstall "$prog"
done
fi
}
# shellcheck disable=SC2068
fzf-brew-uninstall $@