-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-links.sh
executable file
·81 lines (74 loc) · 2.44 KB
/
setup-links.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
#!/bin/bash
printout=""
if [[ $1 == "-l" ]]; then
echo printing only
printout="1"
fi
function backup_and_link() {
if [[ "$3" == "sudo" ]]; then # handle sudo
ELEV="sudo "
else
ELEV=""
fi
if [[ $printout == "1" ]]; then
echo '#' ${ELEV} ln -s "$PWD/$1" "${2%/}"
else
echo "Linking $1 out to $2"
if [[ -d "$2" ]] || [[ -f "$2" ]]; then # if file or folder exists
${ELEV} mv "${2%/}" "${2%/}.old" # move to .old
else
${ELEV} mkdir -p "$(dirname $2)"
fi
${ELEV} ln -s "$PWD/$1" "${2%/}" # create symlink
fi
}
function sudo_replace() {
ELEV="sudo "
if [[ $printout == "1" ]]; then
echo '#' ${ELEV} cp "$PWD/$1" "${2%/}"
else
echo "Copying $1 to $2"
if [[ -d "$2" ]] || [[ -f "$2" ]]; then # if file or folder exists
${ELEV} mv "${2%/}" "${2%/}.old" # move to .old
else
${ELEV} mkdir -p "$(dirname $2)"
fi
${ELEV} cp "$PWD/$1" "${2%/}" # create symlink
fi
}
cd "$(dirname $0)"
backup_and_link gitignore ~/.gitignore
backup_and_link gitmessage ~/.gitmessage
backup_and_link taskrc ~/.taskrc
backup_and_link tmux.conf ~/.tmux.conf
backup_and_link zsh-plugins/themes/pureness.zsh-theme ~/.oh-my-zsh/custom/themes/
backup_and_link zsh-plugins/plugins/custom-aliases/ ~/.oh-my-zsh/custom/plugins/
backup_and_link zsh-plugins/plugins/os-config/ ~/.oh-my-zsh/custom/plugins/
backup_and_link vimrc ~/.vimrc
backup_and_link zshrc ~/.zshrc
if [[ `uname` == "Darwin" ]]; then
backup_and_link latexmkrc_mac ~/.latexmkrc
else
backup_and_link rsync_exclude ~/.rsync_exclude
backup_and_link latexmkrc_linux ~/.latexmkrc
backup_and_link i3blocks.conf ~/.i3blocks.conf
backup_and_link rofi.conf ~/.config/rofi/config
backup_and_link i3.conf ~/.config/i3/config
backup_and_link i3blocks/ ~/.config/i3blocks/
backup_and_link bat.conf ~/.config/bat/config
backup_and_link pulse/client.conf ~/.config/pulse/client.conf
backup_and_link pulse/daemon.conf ~/.config/pulse/daemon.conf
backup_and_link pulse/default.pa ~/.config/pulse/default.pa
backup_and_link profile ~/.profile
sudo_replace [email protected] /etc/systemd/system/[email protected]
sudo_replace [email protected] /etc/systemd/system/[email protected]
if [[ $printout == "1" ]]; then
echo "# sudo systemctl enable resume@$USER"
echo "# sudo systemctl enable suspend@$USER"
else
sudo systemctl enable resume@$USER
sudo systemctl enable suspend@$USER
fi
sudo_replace 30-touchpad.conf /etc/X11/xorg.conf.d/30-touchpad.conf
sudo_replace 99-USBasp.rules /etc/udev/rules.d/99-USBasp.rules
fi