-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·118 lines (111 loc) · 3.33 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
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
#!/usr/bin/env bash
function readLocations() {
echo "Symlinking to the following locations..."
for key in "${!locations[@]}"; do
echo "$key -> ${locations[$key]}"
done
echo ""
}
function installPlugins() {
echo "Installing Vundle..."
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
echo "Installing zplug..."
zplugInstallLoc=$HOME/.zsh/zplug
mkdir -p $zplugInstallLoc
git clone https://github.com/zplug/zplug $zplugInstallLoc
echo "Installing extra scripts..."
scriptInstallLoc=$HOME/.local/bin
mkdir -p $scriptInstallLoc
wget -O $scriptInstallLoc/notify-send.sh https://raw.githubusercontent.com/vlevit/notify-send.sh/master/notify-send.sh
chmod +x $scriptInstallLoc/notify-send.sh
}
force=false
pluginsOnly=false
while getopts "fp" opt; do
case "$opt" in
"f" )
force=true
;;
"p")
pluginsOnly=true
;;
"?")
echo "Usage: ./install.sh [-f] [-p]"
exit 1
;;
esac
done
if $pluginsOnly; then
installPlugins
else
declare -A locations=(
["ctags"]="$HOME/.ctags"\
["i3-config"]="$HOME/.config/i3/config"\
["polybar-config"]="$HOME/.config/polybar/config"\
["rofi"]="$HOME/.config/rofi"\
["scripts"]="$HOME/.local/dotfile-scripts"\
["terminalrc"]="$HOME/.config/xfce4/terminal/terminalrc"\
["vimrc"]="$HOME/.vimrc"\
["zshrc"]="$HOME/.zshrc"\
["services/polybar.service"]="$HOME/.config/systemd/user/polybar.service"\
)
readLocations
satisfied="n"
while [[ $satisfied != "y" ]]; do
locationsSet=false
read -p "Are you satisfied with these locations? (y/n) [y] " satisfied
while [[ $locationsSet == false ]]; do
if [[ $satisfied == "no" ]] || [[ $satisfied == "n" ]]; then
read -p "Name of file to change: " nameToChange
if [[ ! -z ${locations[$nameToChange]} ]]; then
read -p "New path for this file: " newPath
locations[$nameToChange]=$newPath
locationsSet=true
readLocations
else
echo "Not found."
fi
elif [[ $satisfied == "" ]] || [[ $satisfied == "yes" ]] || [[ $satisfied == "y" ]]; then
locationsSet=true
satisfied="y"
fi
done
done
status=0
for key in "${!locations[@]}"; do
fullPath=$(readlink -f $key)
destPath=${locations[$key]}
destDir=$(dirname $destPath)
if [[ ! -d $destDir ]]; then
mkdir -p $destDir
fi
if $force; then
ln -sf $fullPath $destPath
else
ln -s $fullPath $destPath
fi
#If we just set status equal to $?, it checks the status of $status == 0, rather than our ln command
newStatus=$?
if [[ $status == 0 ]]; then
status=$newStatus
fi
done
if [[ $status == 0 ]]; then
echo "Dotfiles have been installed!"
echo "To use the vimrc and the zshrc in this repo, you need Vundle, zplug, and some third party scripts."
shouldInstall="y"
read -p "Would you like to install them? (y/n) [y] " shouldInstall
installChoiceMade=false
while [[ $installChoiceMade == false ]]; do
if [[ $shouldInstall == "" ]] || [[ $shouldInstall == "y" ]] || [[ $shouldInstall == "yes" ]]; then
installPlugins
installChoiceMade=true
elif [[ $shouldInstall == "no" ]] || [[ $shouldInstall == "n" ]]; then
installChoiceMade=true
fi
done
else
echo "Some dotfiles failed to install, probably due to existing symlinks. If you wish to overwrite your existing files, please run this again with the -f flag."
exit 2
fi
fi