Repository navigation
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·168 lines (137 loc) · 4.83 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·168 lines (137 loc) · 4.83 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
#!/usr/bin/env bash
set -euo pipefail
# ---- CONFIG: change this to your actual dotfiles repo ----
DOTFILES_REPO="git@github.com:devroy10/dotfiles.git"
DOTFILES_DIR="$HOME/dotfiles"
# ------------------------------------------------------------
echo "==> Prevent running as root"
if [ "$EUID" -eq 0 ]; then
echo "Do not run this script with sudo"
exit 1
fi
echo "==> Installing base packages"
sudo apt update
sudo apt install -y zsh tmux git curl fonts-powerline kitty fzf
echo "==> Installing Ghostty"
if ! command -v ghostty >/dev/null 2>&1; then
sudo snap install ghostty --classic || true
fi
echo "==> Cloning dotfiles repo"
if [ -d "$DOTFILES_DIR" ]; then
echo "Dotfiles already present, pulling latest"
git -C "$DOTFILES_DIR" pull
else
git clone "$DOTFILES_REPO" "$DOTFILES_DIR"
fi
echo "==> Installing Oh My Zsh (non-interactive)"
if [ ! -d "$HOME/.oh-my-zsh" ]; then
RUNZSH=no CHSH=no KEEP_ZSHRC=yes \
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
echo "==> Installing Powerlevel10k"
P10K_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
if [ ! -d "$P10K_DIR" ]; then
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$P10K_DIR"
fi
# ZSH PLUGINS
echo "==> Installing zsh-autosuggestions"
AUTOSUGGESTIONS_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autosuggestions"
if [ ! -d "$AUTOSUGGESTIONS_DIR" ]; then
git clone --depth=1 \
https://github.com/zsh-users/zsh-autosuggestions \
"$AUTOSUGGESTIONS_DIR"
fi
echo "==> Installing zsh-syntax-highlighting"
SYNTAX_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting"
if [ ! -d "$SYNTAX_DIR" ]; then
git clone --depth=1 \
https://github.com/zsh-users/zsh-syntax-highlighting \
"$SYNTAX_DIR"
fi
echo "==> Installing fzf-tab"
FZF_TAB_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fzf-tab"
if [ ! -d "$FZF_TAB_DIR" ]; then
git clone --depth=1 \
https://github.com/Aloxaf/fzf-tab \
"$FZF_TAB_DIR"
fi
echo "==> Installing zsh-autocomplete"
AUTOCOMPLETE_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/zsh-autocomplete"
if [ ! -d "$AUTOCOMPLETE_DIR" ]; then
git clone --depth=1 \
https://github.com/marlonrichert/zsh-autocomplete \
"$AUTOCOMPLETE_DIR"
fi
# PLUGIN MANAGER
echo "==> Installing tmux plugin manager (TPM)"
TPM_DIR="$HOME/.tmux/plugins/tpm"
if [ ! -d "$TPM_DIR" ]; then
git clone --depth=1 https://github.com/tmux-plugins/tpm "$TPM_DIR"
fi
echo "==> Backing up any existing configs"
TIMESTAMP=$(date +%Y%m%d%H%M%S)
for f in .zshrc .zshenv .p10k.zsh .tmux.conf; do
if [ -e "$HOME/$f" ] && [ ! -L "$HOME/$f" ]; then
mv "$HOME/$f" "$HOME/$f.bak.$TIMESTAMP"
echo "Backed up existing $f -> $f.bak.$TIMESTAMP"
fi
done
if [ ! -f "$DOTFILES_DIR/.zshrc" ]; then
echo "Missing .zshrc in dotfiles repo"
exit 1
fi
if [ ! -f "$DOTFILES_DIR/.tmux.conf" ]; then
echo "Missing .tmux.conf in dotfiles repo"
exit 1
fi
if [ ! -f "$DOTFILES_DIR/.p10k.zsh" ]; then
echo "Missing .p10k.zsh in dotfiles repo"
exit 1
fi
if [ ! -f "$DOTFILES_DIR/.zshenv" ]; then
echo "Missing .zshenv in dotfiles repo"
exit 1
fi
# SYMLINK TO DOTFILES
echo "==> Symlinking configs"
ln -sf "$DOTFILES_DIR/.zshrc" "$HOME/.zshrc"
ln -sf "$DOTFILES_DIR/.zshenv" "$HOME/.zshenv"
ln -sf "$DOTFILES_DIR/.p10k.zsh" "$HOME/.p10k.zsh"
ln -sf "$DOTFILES_DIR/.tmux.conf" "$HOME/.tmux.conf"
echo "==> Installing tmux plugins"
if [ -x "$TPM_DIR/bin/install_plugins" ]; then
"$TPM_DIR/bin/install_plugins"
fi
echo "==> Updating tmux plugins"
if [ -x "$TPM_DIR/bin/update_plugins" ]; then
"$TPM_DIR/bin/update_plugins" || true
fi
echo "==> Setting zsh as default shell"
if [ "$SHELL" != "$(which zsh)" ]; then
sudo chsh -s "$(which zsh)" "$USER"
fi
echo "==> Setting up Ghostty config"
mkdir -p "$HOME/.config/ghostty"
if [ -f "$DOTFILES_DIR/ghostty/config" ]; then
ln -sf "$DOTFILES_DIR/ghostty/config" \
"$HOME/.config/ghostty/config"
fi
echo "==> Setting up Kitty config"
mkdir -p "$HOME/.config/kitty"
if [ -f "$DOTFILES_DIR/kitty/kitty.conf" ]; then
ln -sf "$DOTFILES_DIR/kitty/kitty.conf" \
"$HOME/.config/kitty/kitty.conf"
fi
echo "==> Making Ghostty the default terminal"
if command -v ghostty >/dev/null 2>&1; then
GHOSTTY_BIN="$(which ghostty)"
sudo update-alternatives --install /usr/bin/x-terminal-emulator \
x-terminal-emulator "$GHOSTTY_BIN" 60 || true
sudo update-alternatives --set x-terminal-emulator "$GHOSTTY_BIN" || true
gsettings set org.gnome.desktop.default-applications.terminal exec 'ghostty' || true
gsettings set org.gnome.desktop.default-applications.terminal exec-arg '' || true
fi
echo "==> Done."
echo "Reminder: install a Nerd Font (e.g. MesloLGS NF) on this machine's"
echo "terminal emulator/GUI for Powerlevel10k icons to render correctly —"
echo "this can't be done by a shell script alone (it's a terminal setting)."