Skip to content

Commit 8f451e0

Browse files
authored
Create starfish.sh
1 parent 7616eb8 commit 8f451e0

1 file changed

Lines changed: 145 additions & 0 deletions

File tree

‎shell/starfish.sh‎

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
6+
echo " Fish + Starship Installer"
7+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
8+
9+
# Root check
10+
if [ "$EUID" -eq 0 ]; then
11+
USER_HOME="/root"
12+
USER_NAME="root"
13+
else
14+
USER_HOME="$HOME"
15+
USER_NAME="$(whoami)"
16+
fi
17+
18+
echo
19+
echo "📦 Installing Fish..."
20+
21+
if command -v apt >/dev/null 2>&1; then
22+
apt update
23+
apt install -y fish curl
24+
elif command -v dnf >/dev/null 2>&1; then
25+
dnf install -y fish curl
26+
elif command -v yum >/dev/null 2>&1; then
27+
yum install -y fish curl
28+
elif command -v pacman >/dev/null 2>&1; then
29+
pacman -Sy --noconfirm fish curl
30+
else
31+
echo "Unsupported package manager."
32+
exit 1
33+
fi
34+
35+
echo
36+
echo "⭐ Installing Starship..."
37+
38+
curl -sS https://starship.rs/install.sh | sh -s -- -y
39+
40+
mkdir -p "$USER_HOME/.config/fish"
41+
42+
cat > "$USER_HOME/.config/fish/config.fish" <<'EOF'
43+
starship init fish | source
44+
EOF
45+
46+
mkdir -p "$USER_HOME/.config"
47+
48+
cat > "$USER_HOME/.config/starship.toml" <<'EOF'
49+
add_newline = true
50+
51+
format = """
52+
╭─$username$hostname
53+
├─$directory$git_branch$git_status
54+
╰─$character
55+
"""
56+
57+
[username]
58+
show_always = true
59+
style_user = "bold #00D7C3"
60+
style_root = "bold #00D7C3"
61+
format = "[$user]($style)"
62+
63+
[hostname]
64+
ssh_only = false
65+
style = "bold white"
66+
format = "[@$hostname]($style)"
67+
68+
[directory]
69+
style = "#E8E8E8"
70+
truncation_length = 3
71+
truncate_to_repo = false
72+
read_only = " 🔒"
73+
format = "[$path]($style)"
74+
75+
[git_branch]
76+
symbol = " ("
77+
format = " [$branch)](bold #00D7C3)"
78+
79+
[git_status]
80+
format = " [$all_status$ahead_behind](yellow)"
81+
82+
[character]
83+
success_symbol = "[❯](bold #00D7C3)"
84+
error_symbol = "[❯](bold #FF5C7A)"
85+
vimcmd_symbol = "[❮](bold #00D7C3)"
86+
87+
[package]
88+
disabled = true
89+
90+
[nodejs]
91+
disabled = true
92+
93+
[python]
94+
disabled = true
95+
96+
[rust]
97+
disabled = true
98+
99+
[golang]
100+
disabled = true
101+
102+
[docker_context]
103+
disabled = true
104+
105+
[kubernetes]
106+
disabled = true
107+
108+
[aws]
109+
disabled = true
110+
111+
[gcloud]
112+
disabled = true
113+
114+
[time]
115+
disabled = true
116+
EOF
117+
118+
echo
119+
read -rp "Change default shell to Fish? (Y/n): " ans
120+
121+
if [[ ! "$ans" =~ ^[Nn]$ ]]; then
122+
FISH_PATH=$(command -v fish)
123+
124+
if ! grep -q "$FISH_PATH" /etc/shells; then
125+
echo "$FISH_PATH" >> /etc/shells
126+
fi
127+
128+
chsh -s "$FISH_PATH" "$USER_NAME" || true
129+
fi
130+
131+
echo
132+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
133+
echo " Installation Complete!"
134+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
135+
echo
136+
echo "Restart your SSH session or run:"
137+
echo
138+
echo " exec fish"
139+
echo
140+
echo "Expected prompt:"
141+
echo
142+
echo "╭─ root@Console"
143+
echo "├─ /opt/pasarguard (main)"
144+
echo "╰─❯"
145+
echo

0 commit comments

Comments
 (0)