-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·63 lines (55 loc) · 2.25 KB
/
install.sh
File metadata and controls
executable file
·63 lines (55 loc) · 2.25 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
# shint installer — adds shint to your .bashrc
set -euo pipefail
SHINT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SHINT_SCRIPT="$SHINT_DIR/shint.bash"
BASHRC="${HOME}/.bashrc"
MARKER="# shint"
echo "shint installer"
echo "==============="
echo ""
# ─── Check bash version ─────────────────────────────────────────────
current_bash="${BASH_VERSION%%(*}"
bash_major="${current_bash%%.*}"
if [[ "$bash_major" -lt 4 ]]; then
echo "WARNING: your current bash is $BASH_VERSION."
echo "shint requires bash 4.0+."
echo ""
if command -v /opt/homebrew/bin/bash &>/dev/null; then
echo "You have a modern bash at /opt/homebrew/bin/bash. To switch:"
echo " sudo sh -c 'grep -qxF /opt/homebrew/bin/bash /etc/shells || echo /opt/homebrew/bin/bash >> /etc/shells'"
echo " chsh -s /opt/homebrew/bin/bash"
elif command -v /usr/local/bin/bash &>/dev/null; then
echo "You have a modern bash at /usr/local/bin/bash. To switch:"
echo " sudo sh -c 'grep -qxF /usr/local/bin/bash /etc/shells || echo /usr/local/bin/bash >> /etc/shells'"
echo " chsh -s /usr/local/bin/bash"
else
echo "Install modern bash first: brew install bash"
fi
echo ""
fi
# ─── Check dependencies ─────────────────────────────────────────────
echo "Dependencies:"
ok=true
for cmd in carapace fzf; do
if command -v "$cmd" &>/dev/null; then
printf " %-10s %s\n" "$cmd" "$(command -v "$cmd")"
else
printf " %-10s MISSING — brew install %s\n" "$cmd" "$cmd"
ok=false
fi
done
echo ""
$ok || { echo "Install missing dependencies first."; exit 1; }
# ─── Add to .bashrc ─────────────────────────────────────────────────
if grep -qF "$MARKER" "$BASHRC" 2>/dev/null; then
echo "shint is already in $BASHRC — skipping."
else
cat >> "$BASHRC" << EOF
$MARKER
source "$SHINT_SCRIPT"
EOF
echo "Added shint to $BASHRC"
fi
echo ""
echo "Done! Restart your terminal or run: source $BASHRC"