-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·131 lines (105 loc) · 2.81 KB
/
setup.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
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
#!/bin/bash
DIR=$(cd `dirname $0` && pwd)
if [ "$DIR" != "$HOME/.dotfiles" ]; then
echo "The dotfiles directory must be $HOME/.dotfiles to run the setup script"
exit 1
fi
mkdir -p $HOME/.config &> /dev/null
SUDO="sudo -l -U $USER &> /dev/null || return"
function simple_link {
name=$1
rm -rf $HOME/.config/$1 &> /dev/null
ln -s $DIR/$1 $HOME/.config/$1
}
# if the config resides in $HOME/.config, create a symlink for the whole dir
# otherwise, only link necessary files to avoid extra files getting tracked
function __git {
ln -sf $DIR/git/gitignore_global $HOME/.gitignore_global
git config --global core.excludesfile $HOME/.gitignore_global
git config --global user.name "Chen Chen"
git config --global user.email "[email protected]"
git config --global user.signkey "E6F1F8B1C9E2624D"
git config --global commit.gpgsign "true"
}
function __vim {
mkdir -p $HOME/.vim &> /dev/null
ln -sf $DIR/vim/vimrc $HOME/.vim/vimrc
rm -rf $HOME/.vim/syntax
ln -sf $DIR/vim/syntax $HOME/.vim/syntax
}
function __nvim {
simple_link nvim
}
function __i3 {
simple_link i3
}
function __tmux {
ln -sf $DIR/tmux/tmux.conf $HOME/.tmux.conf
}
function __x11 {
ln -sf $DIR/x11/xinitrc $HOME/.xinitrc
ln -sf $DIR/x11/Xresources $HOME/.Xresources
ln -sf $DIR/x11/user-dirs.dirs $HOME/.config/user-dirs.dirs
eval $SUDO
sudo cp $DIR/x11/xorg.conf.d/*.conf /etc/X11/xorg.conf.d/
}
function __bash {
ln -sf $DIR/bash/bash_profile $HOME/.bash_profile
ln -sf $DIR/bash/bashrc $HOME/.bashrc
}
function __fontconfig {
simple_link fontconfig
}
function __modprobe {
eval $SUDO
sudo cp $DIR/modprobe/* /etc/modprobe.d/
}
function __pacman {
eval $SUDO
sudo cp $DIR/pacman/pacman.conf /etc/pacman.conf
sudo cp $DIR/pacman/gnupg/gpg.conf /etc/pacman.d/gnupg/gpg.conf
}
function __xsecurelock {
ln -sf $DIR/xsecurelock/lock.sh $HOME/.lock.sh
}
function __alacritty {
simple_link alacritty
}
function __picom {
simple_link picom
}
function __polybar {
simple_link polybar
}
function __rofi {
simple_link rofi
}
function __gtk {
ln -sf $DIR/gtk/gtkrc-2.0 $HOME/.gtkrc-2.0
}
function __gnupg {
mkdir -p $HOME/.gnupg &> /dev/null
chmod 700 $HOME/.gnupg
rm $HOME/.gnupg/*.conf &> /dev/null
ln -sf $DIR/gnupg/*.conf $HOME/.gnupg/
}
function __gdb {
rm -f $HOME/.gdb-dashboard
rm -f $HOME/.gdbinit
git submodule update gdb/gdb-dashboard
ln -sf $DIR/gdb/gdbinit $HOME/.gdbinit
ln -sf $DIR/gdb/gdb-dashboard/.gdbinit $HOME/.gdb-dashboard
}
source config
for f in $(compgen -A function); do
if [ "${f::2}" != "__" ]; then
continue
fi
F=`echo "$f" | tr '[:lower:]' '[:upper:]'`
if [ "${!F}" == "y" ]; then
echo "setup: "$f
$f
else
echo "skip: "$f
fi
done