-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
executable file
·61 lines (48 loc) · 1.16 KB
/
setup
File metadata and controls
executable file
·61 lines (48 loc) · 1.16 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
#!/usr/bin/env bash
# -f is set then overwrite existing files
git config --global core.editor "nvim"
git config --global user.name "Salman Sarray"
git config --global user.email "salman@sarray.de"
git config --global init.defaultBranch main
git config --global pull.rebase false
echo "[...git..] configured."
config="$HOME/.config"
paths=( "$config/nvim" "$config/neomutt" "$config/ghostty" "$config/newsraft" "$HOME/.tmux.conf" "$HOME/.zshrc" "$HOME/.xinitrc" "$HOME/.local/bin" "$HOME/.XCompose" "$HOME/.mbsyncrc" )
force=0
usage() {
echo "Usage: $0 [-f]"
exit 1
}
force-usage() {
echo "[dotfiles] Use -f to force overwrite."
exit 1
}
if [ "$1" = "-f" ]; then
force=1
for path in "${paths[@]}"; do
rm -rf "$path"
echo "[dotfiles] $path removed."
done
elif [ -n "$1" ]; then
usage
fi
path_exists=0
for path in "${paths[@]}"; do
if [ -e "$path" ]; then
path_exists=1
echo "[dotfiles] $path already exists."
continue
fi
from="$(pwd)/${path#$HOME/}"
to="$path"
if [ -d "$to" ]; then
ln -nfs "$from" "$to"
fi
ln -s "$from" "$to"
echo "[dotfiles] $to -> $from"
done
if [ $path_exists -eq 1 ]; then
force-usage
else
echo "[dotfiles] files linked."
fi