-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·249 lines (226 loc) · 9.5 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·249 lines (226 loc) · 9.5 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/usr/bin/env bash
# Setup script for dotfiles, this will install all necessary components
# for a complete terminal setup.
# This setup is based on Oh-My-Zsh, Powerlevel 9k and the Mononoki font
set -e
FONTS_DIR="$HOME/.local/share/fonts"
function switch_to_zsh {
if [ "$(basename "$SHELL")" != "zsh" -a -f "$(which zsh)" ]; then
echo "Switching default shell to zsh, please enter your password:"
chsh -s $(which zsh)
fi
}
function install_ohmyzsh {
if [ ! -d "$HOME/.oh-my-zsh" ]
then
echo "[INSTALL] Installing oh-my-zsh"
if [ "$(which curl)" ]; then
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
elif [ "$(which wget)" ]; then
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
fi
# Check that OhMyZsh as been installed and create custom plugin dir
if [ -f "$HOME/.oh-my-zsh/oh-my-zsh.sh" ]; then
mkdir -p ~/.oh-my-zsh/custom/plugins
fi
else
echo "[SKIP] oh-my-zsh is already installed"
fi
}
function install_ohmyzsh_plugins {
if [ -d $HOME/.oh-my-zsh/custom ]; then
if [ ! -d "$HOME/.oh-my-zsh/custom/plugins/grunt" ]; then
echo "[INSTALL] zsh Grunt plugin"
mkdir -p ~/.oh-my-zsh/custom/plugins
git clone https://github.com/yonchu/grunt-zsh-completion.git ~/.oh-my-zsh/custom/plugins/grunt
fi
if [ ! -d "$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting" ]; then
echo "[INSTALL] zsh syntax highlighting"
mkdir -p ~/.oh-my-zsh/custom/plugins
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting/
fi
if [ ! -d "$HOME/.oh-my-zsh/custom/plugins/git-flow-completion" ]; then
echo "[INSTALL] zsh git flow completion"
git clone https://github.com/bobthecow/git-flow-completion ~/.oh-my-zsh/custom/plugins/git-flow-completion
fi
if [ ! -d "$HOME/.oh-my-zsh/custom/themes/powerlevel9k" ]; then
echo "[INSTALL] powerlevel9k theme"
mkdir -p ~/.oh-my-zsh/custom/themes/
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
fi
if [ ! -d "$HOME/.oh-my-zsh/custom/themes/powerlevel10k" ]; then
echo "[INSTALL] powerlevel10k theme"
git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
fi
fi
}
function link_file {
source="${PWD}/$1"
if [[ "${2}" ]]; then
target="${2}/${1}"
else
target="${HOME}/.${1}"
fi
if [ -e "${target}" ]
then
if [ "_$(readlink ${target})" == "_${source}" ]
then
echo "[SKIP] Existing target ${target}, skipping file $1"
return
else
backup=$target.backup$(date +%s)
echo "[BACKUP] Saving backup of exising file ${target} as ${backup}"
mv $target $backup
fi
fi
echo "[ OK ] Creating link to ${source}"
ln -sf ${source} ${target}
}
function check_inotify_watches {
# Check that the running system has enough inotify watches
watches=$(cat /proc/sys/fs/inotify/max_user_watches)
if [ $watches -lt 524288 ]; then
echo "*********************************************************************"
echo "*********************************************************************"
echo "*********************************************************************"
echo "*********************************************************************"
echo "***** *****"
echo "***** *****"
echo "***** YOUR NUMBER OF INOTIFY WATCHES IS DANGEROUSLY LOW. *****"
echo "***** SEVERAL TOOLS SUCH AS TAIL, LIVERELOAD AND DROPBOX *****"
echo "***** WON'T WORK PROPERLY. *****"
echo "***** *****"
echo "***** PLEASE FIX THIS ASAP!! RUN AS ROOT: *****"
echo "***** *****"
echo "***** echo 1048576 > /proc/sys/fs/inotify/max_user_watches *****"
echo "*****echo fs.inotify.max_user_watches=1048576 >> /etc/sysctl.conf*****"
echo "***** *****"
echo "***** *****"
echo "*********************************************************************"
echo "*********************************************************************"
echo "*********************************************************************"
echo "*********************************************************************"
fi
}
function install_powerline_fonts {
mkdir -p $FONTS_DIR
git clone https://github.com/powerline/fonts.git powerline-fonts
cd powerline-fonts
./install.sh
cd ..
rm -rf powerline-fonts
}
function install_awesome_fonts {
mkdir -p $FONTS_DIR
git clone https://github.com/gabrielelana/awesome-terminal-fonts.git
cd awesome-terminal-fonts
git checkout patching-strategy
cd patched
cp *.ttf $FONTS_DIR
cd ../..
rm -rf awesome-terminal-fonts
}
function install_nerd_fonts {
cd $FONTS_DIR
wget "https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/Mononoki/Regular/MononokiNerdFontMono-Regular.ttf"
}
function install_font() {
# Install a font compatible with PowerLevel 9k
mkdir -p $FONTS_DIR
# install_powerline_fonts
# install_awesome_fonts
install_nerd_fonts
fc-cache -f -v
}
install_kde_config() {
# Install KDE config if running KDE/Plasma
if [ "$XDG_CURRENT_DESKTOP" = "KDE" ] || [ "$KDE_FULL_SESSION" = "true" ]; then
echo "[INSTALL] Installing KDE configuration"
mkdir -p "$HOME/.config"
if [ -f "$HOME/.config/kdeglobals" ]; then
# Merge settings using kwriteconfig6 if available
if [ "$(which kwriteconfig6)" ]; then
kwriteconfig6 --file kdeglobals --group KDE --key SingleClick true
echo "[ OK ] KDE SingleClick enabled via kwriteconfig6"
else
echo "[SKIP] kwriteconfig6 not found, skipping KDE config"
fi
else
ln -sf "${PWD}/kde/kdeglobals" "$HOME/.config/kdeglobals"
echo "[ OK ] Linked kdeglobals"
fi
else
echo "[SKIP] KDE not detected, skipping KDE config"
fi
}
install_kwin_rules() {
# Install KWin window rules (merged into existing kwinrulesrc).
if [ "$XDG_CURRENT_DESKTOP" != "KDE" ] && [ "$KDE_FULL_SESSION" != "true" ]; then
echo "[SKIP] KDE not detected, skipping KWin rules"
return
fi
if ! command -v kwriteconfig6 >/dev/null 2>&1; then
echo "[SKIP] kwriteconfig6 not found, skipping KWin rules"
return
fi
echo "[INSTALL] Installing KWin window rules"
# Rule: VS Code — disable focus stealing prevention / protection.
local uuid="0863600a-ba7b-48d1-b6c2-59f28b10fc13"
kwriteconfig6 --file kwinrulesrc --group "$uuid" --key Description "VS Code — no focus stealing prevention"
kwriteconfig6 --file kwinrulesrc --group "$uuid" --key wmclass '^[Cc]ode$'
kwriteconfig6 --file kwinrulesrc --group "$uuid" --key wmclassmatch 3
kwriteconfig6 --file kwinrulesrc --group "$uuid" --key wmclasscomplete false
kwriteconfig6 --file kwinrulesrc --group "$uuid" --key fsplevel 0
kwriteconfig6 --file kwinrulesrc --group "$uuid" --key fsplevelrule 2
kwriteconfig6 --file kwinrulesrc --group "$uuid" --key fpplevel 0
kwriteconfig6 --file kwinrulesrc --group "$uuid" --key fpplevelrule 2
# Add UUID to General/rules if not already present, then refresh count.
local current_rules
current_rules=$(kreadconfig6 --file kwinrulesrc --group General --key rules 2>/dev/null)
if ! echo "$current_rules" | tr ',' '\n' | grep -Fxq "$uuid"; then
if [ -z "$current_rules" ]; then
kwriteconfig6 --file kwinrulesrc --group General --key rules "$uuid"
else
kwriteconfig6 --file kwinrulesrc --group General --key rules "${current_rules},${uuid}"
fi
fi
local rule_count
rule_count=$(kreadconfig6 --file kwinrulesrc --group General --key rules | tr ',' '\n' | grep -c .)
kwriteconfig6 --file kwinrulesrc --group General --key count "$rule_count"
# Tell KWin to reload.
if command -v qdbus >/dev/null 2>&1; then
qdbus org.kde.KWin /KWin reconfigure >/dev/null 2>&1 || true
fi
echo "[ OK ] KWin rule installed: VS Code no-focus-stealing"
}
function install_fzf() {
if [ ! -d "$HOME/.fzf" ]; then
git clone --depth 1 https://github.com/junegunn/fzf.git $HOME/.fzf
~/.fzf/install --no-update-rc
fi
}
link_file vim
link_file vimrc
mkdir -p "$HOME/.config"
link_file nvim "$HOME/.config"
link_file bashrc
link_file zshrc
link_file screenrc
link_file gitconfig
link_file gitignore_global
link_file hgrc
link_file tmux.conf
link_file dput.cf
link_file mancolor
link_file xbindkeysrc
link_file shell_functions.sh
link_file rpmmacros
link_file robots.sh
install_ohmyzsh
install_ohmyzsh_plugins
install_fzf
install_font
install_kde_config
install_kwin_rules
check_inotify_watches
switch_to_zsh