-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathx.sh
More file actions
211 lines (183 loc) · 6.19 KB
/
Copy pathx.sh
File metadata and controls
211 lines (183 loc) · 6.19 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/usr/bin/env bash
set -euo pipefail
# X base
if [[ ! -x /usr/bin/x ]] || ! grep -q 'exec sudo "$@"' /usr/bin/x 2>/dev/null; then
sudo sh -c 'cat > /usr/bin/x << "EOF"
#!/usr/bin/env bash
exec sudo "$@"
EOF'
sudo chmod 755 /usr/bin/x
fi
alias x &>/dev/null && unalias x || true
if [[ -n "${RCFILE:-}" ]] && [[ -f "$RCFILE" ]]; then
sed -i '/^[[:space:]]*alias[[:space:]]*x=.*$/d' "$RCFILE" || true
fi
if [[ -f "$HOME/.zshrc" ]]; then
sed -i '/^[[:space:]]*alias[[:space:]]*x=.*$/d' "$HOME/.zshrc" || true
fi
if [[ -f /etc/bash.bashrc ]]; then
x sed -i '/^[[:space:]]*alias[[:space:]]*x=.*$/d' /etc/bash.bashrc || true
fi
if [[ -f /etc/zsh/zshrc ]]; then
x sed -i '/^[[:space:]]*alias[[:space:]]*x=.*$/d' /etc/zsh/zshrc || true
fi
ALIASES="
# ───── Xscriptor Aliases ─────
alias xs='sudo su'
alias xi='sudo -i'
alias xsh='sudo -s'
alias xzdev='zellij --layout x'
"
shopt -s expand_aliases
alias xs='sudo su'
alias xi='sudo -i'
alias xsh='sudo -s'
alias xzdev='zellij --layout x'
if ! command -v zsh &>/dev/null; then
if command -v pacman &>/dev/null; then
x pacman -Sy --noconfirm zsh
elif command -v apt &>/dev/null; then
x apt update -y
x apt install -y zsh
elif command -v dnf &>/dev/null; then
x dnf install -y zsh
fi
fi
# Install yay only if Arch-based
if command -v pacman &>/dev/null; then
if ! command -v yay &>/dev/null; then
echo "[+] Installing yay (AUR helper)..."
x pacman -Sy --noconfirm --needed git base-devel
tmpdir=$(mktemp -d)
git clone https://aur.archlinux.org/yay.git "$tmpdir"
(cd "$tmpdir" && makepkg -si --noconfirm)
rm -rf "$tmpdir"
else
echo "[=] yay already installed"
fi
fi
if [ "$SHELL" != "$(which zsh)" ] && command -v zsh &>/dev/null; then
chsh -s "$(which zsh)"
fi
if [ ! -d "$HOME/.oh-my-zsh" ]; then
export RUNZSH=no
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
declare -A plugins=(
["zsh-autosuggestions"]="https://github.com/zsh-users/zsh-autosuggestions"
["zsh-syntax-highlighting"]="https://github.com/zsh-users/zsh-syntax-highlighting"
["zsh-completions"]="https://github.com/zsh-users/zsh-completions"
["zsh-autocomplete"]="https://github.com/marlonrichert/zsh-autocomplete"
)
for name in "${!plugins[@]}"; do
dest="$ZSH_CUSTOM/plugins/$name"
if [ ! -d "$dest" ]; then
git clone --depth=1 "${plugins[$name]}" "$dest"
fi
done
ZSHRC="$HOME/.zshrc"
sed -i 's/^ZSH_THEME=.*/ZSH_THEME="random"/' "$ZSHRC" || echo 'ZSH_THEME="random"' >> "$ZSHRC"
if grep -q "^plugins=" "$ZSHRC"; then
sed -i 's/^plugins=.*/plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions zsh-autocomplete)/' "$ZSHRC"
else
echo 'plugins=(git zsh-autosuggestions zsh-syntax-highlighting zsh-completions zsh-autocomplete)' >> "$ZSHRC"
fi
GIT_ALIASES=$(cat <<'EOF'
# ===== XCustom Git Aliases =====
alias gc="git clone"
alias ga="git add ."
alias gcom="git commit -m"
alias gp="git push"
alias gpuom="git push -u origin main"
alias gpuod="git push -u origin dev"
alias gs="git status"
alias gl="git log --oneline --graph --decorate"
alias gco="git checkout"
alias gcb="git checkout -b"
alias gd="git diff"
alias gpl="git pull"
alias gf="git fetch"
# ===== End =====
EOF
)
NAVIGATION_ALIASES=$(cat <<'EOF'
# ===== XCustom Navigation Aliases =====
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias ~="cd ~"
alias c="clear"
alias ll="ls -lh"
alias la="ls -A"
alias l="ls -CF"
# ===== End =====
EOF
)
# Detect shell rc file
RCFILE=""
case "$(basename "$SHELL")" in
bash) RCFILE="$HOME/.bashrc" ;;
zsh) RCFILE="$HOME/.zshrc" ;;
esac
# Add to user shell rc
if [[ -n "$RCFILE" ]]; then
if ! grep -q "Xscriptor Aliases" "$RCFILE" 2>/dev/null; then
echo "$ALIASES" >> "$RCFILE"
echo "[+] Aliases added to $RCFILE"
else
echo "[=] Aliases already exist in $RCFILE"
fi
else
echo "[!] Unsupported shell. Add manually."
fi
if [[ -n "$RCFILE" ]]; then
if ! grep -q "XCustom Git Aliases" "$RCFILE" 2>/dev/null; then
echo "$GIT_ALIASES" >> "$RCFILE"
fi
if ! grep -q "XCustom Navigation Aliases" "$RCFILE" 2>/dev/null; then
echo "$NAVIGATION_ALIASES" >> "$RCFILE"
fi
fi
if [[ -f /etc/bash.bashrc ]]; then
if ! grep -q "Xscriptor Aliases" /etc/bash.bashrc 2>/dev/null; then
echo "$ALIASES" | x tee -a /etc/bash.bashrc >/dev/null
fi
if ! grep -q "XCustom Git Aliases" /etc/bash.bashrc 2>/dev/null; then
echo "$GIT_ALIASES" | x tee -a /etc/bash.bashrc >/dev/null
fi
if ! grep -q "XCustom Navigation Aliases" /etc/bash.bashrc 2>/dev/null; then
echo "$NAVIGATION_ALIASES" | x tee -a /etc/bash.bashrc >/dev/null
fi
fi
if [[ -f /etc/zsh/zshrc ]]; then
if ! grep -q "Xscriptor Aliases" /etc/zsh/zshrc 2>/dev/null; then
echo "$ALIASES" | x tee -a /etc/zsh/zshrc >/dev/null
fi
if ! grep -q "XCustom Git Aliases" /etc/zsh/zshrc 2>/dev/null; then
echo "$GIT_ALIASES" | x tee -a /etc/zsh/zshrc >/dev/null
fi
if ! grep -q "XCustom Navigation Aliases" /etc/zsh/zshrc 2>/dev/null; then
echo "$NAVIGATION_ALIASES" | x tee -a /etc/zsh/zshrc >/dev/null
fi
fi
if ! grep -q "Xscriptor Aliases" "$HOME/.zshrc" 2>/dev/null; then
echo "$ALIASES" >> "$HOME/.zshrc"
fi
if ! grep -q "XCustom Git Aliases" "$HOME/.zshrc" 2>/dev/null; then
echo "$GIT_ALIASES" >> "$HOME/.zshrc"
fi
if ! grep -q "XCustom Navigation Aliases" "$HOME/.zshrc" 2>/dev/null; then
echo "$NAVIGATION_ALIASES" >> "$HOME/.zshrc"
fi
if command -v code &>/dev/null; then
code --install-extension xscriptor.x-dark-colors || echo "[!] Failed to install xscriptor.x-dark-colors"
code --install-extension xscriptor.xscriptor-themes || echo "[!] Failed to install xscriptor.xscriptor-themes"
code --install-extension xscriptor.xglass || echo "[!] Failed to install xscriptor.xglass"
fi
wget -qO- https://raw.githubusercontent.com/xscriptor/terminal/main/ghostty/install.sh | bash
wget -qO- https://raw.githubusercontent.com/xscriptor/terminal/main/ptyxis/install.sh | bash
curl -fsSL https://raw.githubusercontent.com/xscriptor/xfetch/main/install.sh | bash
curl -fsSL https://raw.githubusercontent.com/xscriptor/xtop/main/install.sh | bash
echo " Done. Reload your shell:"
echo " source ~/.bashrc or source ~/.zshrc"