-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathinstall.sh
executable file
·88 lines (70 loc) · 1.78 KB
/
install.sh
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
#!/bin/bash
: "${XDG_CONFIG_HOME:=$HOME/.config}"
: "${ZDOTDIR:=$HOME}"
echo "== Dots Installer ==="
# Disallow ctrl+c after script start as it may break things
trap "" SIGINT
# Create home if doesn't exists
mkdir -p $XDG_CONFIG_HOME
# Create a backup directory
backup_dir="backup-$(date +%s)"
mkdir -p "$HOME/$backup_dir"
# Create temp directory to cache configs
if [ -d "/tmp/dots" ]; then
rm -rf /tmp/dots
fi
mkdir /tmp/dots
on_exit() {
echo "Clearing cache..."
rm -rf /tmp/dots 2> /dev/null
rm -rf /tmp/scripts 2>/dev/null
}
# Clean temp-cache on exit
trap on_exit EXIT
clone() {
echo "Cloning dots repo..."
git clone /~https://github.com/b4skyx/dotfiles /tmp/dots/
echo "Cloning scripts repo..."
git clone /~https://github.com/b4skyx/unix-scripts /tmp/dots/scripts/
}
backup() {
cd /tmp/dots/.config/
echo "Creating backups for old configs..."
for conf in *; do
if [ -d "$XDG_CONFIG_HOME/$conf" ]; then
mv "$XDG_CONFIG_HOME/$conf" "$HOME/$backup_dir"
echo "Backed up: $conf"
fi
done
cd /tmp/dots/zsh/
mkdir -p "$HOME/$backup_dir/zsh/"
echo "Backing up ZSH config..."
for conf in .*; do
if [ -d "$ZDOTDIR/$conf" ]; then
mv "$ZDOTDIR/$conf" "$HOME/$backup_dir/zsh/" 2>/dev/null
fi
done
cp "$HOME/.Xresources" "$HOME/$backup_dir/"
echo "Configuration backup complete! Backup Folder: $backup_dir"
}
configure() {
cd /tmp/dots/.config/
echo "Creating backups for old configs..."
for conf in *; do
cp -rp "$conf" "$XDG_CONFIG_HOME"
done
cd /tmp/dots/zsh/
for conf in .*; do
cp -rp "$conf" "$ZDOTDIR" 2>/dev/null
done
cd /tmp/dots/.fonts
for conf in *; do
cp -rp "$conf" "$HOME/.fonts/" 2>/dev/null
done
cp /tmp/dots/.Xresources "$HOME/.Xresources"
cp /tmp/dots/.quotes "$HOME/.quotes"
echo "Configured successfully! @b4skyx :D"
}
clone
backup
configure