-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·120 lines (97 loc) · 2.47 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·120 lines (97 loc) · 2.47 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
DOTS="$(readlink -f $(dirname $0))"
add_link() {
file="${DOTS}/${1}"
echo "Linking ${file} to ${2}"
ln -s "${file}" "${2}"
}
add_source() {
command="source ${DOTS}/${1}"
echo "Adding \"${command}\" to ${2}"
printf "${command}\n" >> ${2}
}
add_include() {
command="\$include ${DOTS}/${1}"
echo "Adding \"${command}\" to ${2}"
printf "${command}\n" >> ${2}
}
clone_repo() {
echo "Cloning ${1} to ${2}"
git clone ${1} ${2}
}
install() {
# Run startup.sh on login.
mkdir -p ~/.config/autostart/
add_link startup.sh.desktop ~/.config/autostart/
add_source .bashrc ~/.bashrc
add_source .vimrc ~/.vimrc
add_source .vim_plugins.vim ~/.vimrc
add_source .tmux.conf ~/.tmux.conf
add_include .inputrc ~/.inputrc
# Install Vundle and Vim plugins.
if [[ ! -d ~/.vim/bundle/Vundle.vim ]]; then
clone_repo https://github.com/VundleVim/Vundle.vim.git \
~/.vim/bundle/Vundle.vim
fi
vim +PluginInstall +qall
mkdir -p ~/.vim/after/ftplugin/
add_link python.vim ~/.vim/after/ftplugin/
mkdir -p ~/.config/rofi/
add_link rofi/config ~/.config/rofi/
add_link rofi/theme.rasi ~/.config/rofi/
mkdir -p ~/.config/i3/
add_link i3/config ~/.config/i3/
mkdir -p ~/.config/i3status/
add_link i3status/config ~/.config/i3status/
}
remove() {
echo "Removing ${1}"
rm -rf ${1}
}
remove_include() {
command="\$include ${DOTS}/${1}"
echo "Removing \"${command}\" from ${2}"
sed -i "\%${command}%d" "${2}"
}
remove_source() {
command="source ${DOTS}/${1}"
echo "Removing \"${command}\" from ${2}"
sed -i "\%${command}%d" "${2}"
}
uninstall() {
read -p "Really uninstall everything? [y/n] " i
if [[ "$i" != "y" ]]; then
exit 1
fi
remove ~/.config/i3/config
remove ~/.config/i3status/config
remove ~/.config/rofi/theme.rasi
remove ~/.config/rofi/config
remove ~/.vim/after/ftplugin/python.vim
# Uninstall Vundle. This leaves the plugins though :(
vim +PluginClean +qall
remove ~/.vim/bundle/Vundle.vim
remove_include .inputrc ~/.inputrc
remove_source .tmux.conf ~/.tmux.conf
remove_source .vim_plugins.vim ~/.vimrc
remove_source .vimrc ~/.vimrc
remove_source .bashrc ~/.bashrc
remove ~/.config/autostart/startup.sh.desktop
}
if [[ "$#" -ne 1 ]]; then
echo "usage: $(basename $0) (-i | -u)" >&2
exit 1
fi
while getopts 'iu' OPTION; do
case "$OPTION" in
i)
install
;;
u)
uninstall
;;
?)
echo "usage: $(basename $0) (-i | -u)" >&2
exit 1
;;
esac
done