Skip to content

Commit 33d7a29

Browse files
committed
feat(hb): add Homebrew convenience tool script
1 parent 5b3da5d commit 33d7a29

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

  • src/.zsh/functions-lazy

src/.zsh/functions-lazy/hb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/zsh
2+
#
3+
# Homebrew convenience tool
4+
# - Require: brew, fzf
5+
#
6+
7+
local BOLD=$'\033[1m'
8+
local GREEN=$'\033[0;32m'
9+
local YELLOW=$'\033[0;33m'
10+
local CYAN=$'\033[0;36m'
11+
local GRAY=$'\033[38;5;242m'
12+
local NC=$'\033[0m'
13+
14+
local action="${1:-upgrade}"
15+
shift 2>/dev/null
16+
17+
case "$action" in
18+
upgrade|up|u)
19+
# Interactively select and upgrade outdated packages
20+
local selected
21+
selected=$(brew outdated --verbose \
22+
| awk '{printf "\033[36m%s\033[0m", $1; sub($1, ""); print}' \
23+
| fzf --multi --ansi --prompt="Select packages to upgrade: ")
24+
if [[ -n "$selected" ]]; then
25+
echo "$selected" | awk '{print $1}' | xargs brew upgrade
26+
fi
27+
;;
28+
help|h|*)
29+
cat << EOF
30+
${BOLD}Homebrew convenience tool${NC}
31+
32+
${CYAN}Usage:${NC} hb <command> [args]
33+
34+
${CYAN}Commands:${NC}
35+
${GREEN}upgrade, up, u${NC} Interactively select and upgrade outdated packages
36+
${GREEN}help, h${NC} Show this help message
37+
38+
${CYAN}Examples:${NC}
39+
hb ${GRAY}# Select and upgrade outdated packages (default)${NC}
40+
hb up ${GRAY}# Same as above${NC}
41+
42+
${CYAN}Requirements:${NC} brew, fzf
43+
EOF
44+
;;
45+
esac

0 commit comments

Comments
 (0)