-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·182 lines (157 loc) · 6.01 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/usr/bin/env bash
#################################
# Move to the directory
#################################
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
cd $DIR
source ./lib_sh/echos.sh
# trap ctrl-c and call ctrl_c()
trap ctrl_c INT
function ctrl_c() {
bot "Interrupting..."
exit 1
}
# Ask for the administrator password upfront
if ! sudo -n true; then
# Ask for the administrator password upfront
bot "I need you to enter your sudo password so I can install some things:"
sudo -v
fi
# Keep-alive: update existing sudo time stamp until the script has finished
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
#################################
# Install required packages
#################################
if which dnf > /dev/null; then
sudo dnf install -y zsh tmux neovim keychain curl git cmake
elif which apt-get > /dev/null; then
sudo apt-add-repository -y ppa:neovim-ppa/stable
sudo apt-get update
sudo apt-get install -y zsh tmux keychain curl git cmake
# Neovim stuff
sudo apt-get install -y software-properties-common
sudo apt-get install -y neovim
elif which brew > /dev/null; then
brew install zsh tmux neovim keychain curl git cmake
else
error "can't install packages"
exit 1;
fi
#################################
# Install oh my zsh
#################################
bot "Installing oh-myh-zsh"
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" 2> /dev/null || true
#################################
# Install powerlevel zsh theme
#################################
bot "Installing powerlevel zsh theme"
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k 2> /dev/null || true
#################################
# Install Pure zsh theme
#################################
bot "Installing Pure zsh theme"
git clone https://github.com/sindresorhus/pure.git ~/.oh-my-zsh/custom/themes/pure 2> /dev/null || true
mkdir -p ~/.oh-my-zsh/custom/functions
ln -s ~/.oh-my-zsh/custom/themes/pure/pure.zsh ~/.oh-my-zsh/custom/functions/prompt_pure_setup 2> /dev/null || true
ln -s ~/.oh-my-zsh/custom/themes/pure/async.zsh ~/.oh-my-zsh/custom/functions/async 2> /dev/null || true
chmod -w ~/.oh-my-zsh/custom/functions
#################################
# Install Zsh Autosuggestions
#################################
git clone git://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions 2> /dev/null
# chmod -w ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
#################################
# Install Zsh History Substring Search
#################################
git clone https://github.com/zsh-users/zsh-history-substring-search ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search 2> /dev/null
# chmod -w ~/.oh-my-zsh/custom/plugins/zsh-history-substring-search
#################################
# Install Zsh Syntax Highlighting
#################################
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting 2> /dev/null
# chmod -w ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
#################################
# Install FZF
#################################
bot "Installing FZF"
if git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf 2> /dev/null ; then
~/.fzf/install
fi
#################################
# Install Pyenv
#################################
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash 2> /dev/null || true
#################################
# Install TPM
#################################
bot "Installing Tmux Plugin Manager"
if git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm 2> /dev/null ; then
bot "Tmux Plugin Manager installed, remember to do 'prefix'+I next time you start Tmux"
fi
#################################
# Copying dotfiles
#################################
bot "Creating symlinks for project dotfiles..."
symlinks() {
local fullsubpath=$1
echo "Creating symlinks for directory $fullsubpath"
shopt -s dotglob
for file in *; do
if [[ $file == "." || $file == ".." ]]; then
continue
fi
# Only files
if [[ -f "$file" ]]; then
if [[ $fullsubpath == "." ]]; then
filefullsubpath=$file
else
filefullsubpath=$fullsubpath/$file
fi
running "~/$filefullsubpath"
# if the file exists:
if [[ -e ~/$filefullsubpath ]]; then
mkdir -p ~/.dotfiles_backup/$now/$fullsubpath
mv ~/$filefullsubpath ~/.dotfiles_backup/$now/$filefullsubpath
echo "backup saved as ~/.dotfiles_backup/$now/$filefullsubpath"
fi
mkdir -p ~/$fullsubpath
# symlink might still exist
unlink ~/$filefullsubpath > /dev/null 2>&1
# create the link
ln -s ${DIR}/homedir/$filefullsubpath ~/$filefullsubpath
echo -en '\tlinked';ok
elif [[ -d "$file" ]]; then
pushd $file > /dev/null 2>&1
if [[ $fullsubpath == "." ]]; then
newpath=$file
else
newpath=${fullsubpath}/${file}
fi
symlinks $newpath
popd > /dev/null 2>&1
fi
done
}
now=$(date +"%Y.%m.%d.%H.%M.%S")
pushd homedir > /dev/null 2>&1
symlinks "."
popd > /dev/null 2>&1
#################################
# Install Vim Plugins
#################################
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim 2> /dev/null
bot "Installing vim plugins"
vim +PluginInstall +qall
nvim +PluginInstall +qall
bot "Done, if you are using Windows, don't forget to add at the beginning of the ~/.bashrc file:
\n\n# Launch Zsh
\nif [ -t 1 ]; then
\n exec zsh
\nfi"