-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.sh
executable file
·98 lines (73 loc) · 2.54 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
#!/usr/bin/env bash
function install_pathogen {
echo "Installing Pathogen"
current_path=$(pwd)
curl -LSso $current_path/vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
}
function install_vim_plug {
echo "Installing Vim Plug"
current_path=$(pwd)
curl -fLo $current_path/vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
}
function setup_vim_plugins {
echo "Installing Vim Plugins"
current_path=$(pwd)
vim_plugins=(
'w0rp/ale'
'fatih/vim-go'
'Yggdroot/indentLine'
'tpope/vim-endwise'
'tpope/vim-fugitive'
'tpope/vim-haml'
'tpope/vim-rails'
)
for plugin in ${vim_plugins[@]}; do
IFS=-/ read -r author plugin_name <<<"$plugin"
install_path=$current_path/vim/bundle/$plugin_name
if [ ! -e $install_path ]; then
echo "Installing $plugin"
git clone https://github.com/$plugin $install_path
fi
done
}
function setup_dotfiles {
echo "Backing up existing dotfiles"
timestamp=`date +%Y%m%d%H%M%S`
declare -a dotfiles
if [[ $(uname) == 'Darwin' ]]; then
dotfiles=($(gfind . -maxdepth 1 -type f ! -name '*.sh' -a ! -name '*.md' -a ! -name '.*' -printf '%f\n'))
else
dotfiles=($(find . -maxdepth 1 -type f ! -name '*.sh' -a ! -name '*.md' -a ! -name '.*' -printf '%f\n'))
fi
current_path=$(pwd)
for dotfile in ${dotfiles[@]}; do
if [ -e $HOME/"."$dotfile ]; then
mv $HOME/"."$dotfile $current_path"/backups/"$timestamp$dotfile
fi
echo "Setting up "$dotfile
ln -s $current_path/$dotfile $HOME/"."$dotfile
done
}
function setup_dot_directories {
echo "Backing up existing dot directories"
timestamp=`date +%Y%m%d%H%M%S`
declare -a dot_directories
if [[ $(uname) == 'Darwin' ]]; then
dot_directories=($(gfind . -maxdepth 1 -type d ! -name 'backups' -a ! -name '.git' -a ! -name '.' -printf '%f\n'))
else
dot_directories=($(find . -maxdepth 1 -type d ! -name 'backups' -a ! -name '.git' -a ! -name '.' -printf '%f\n'))
fi
current_path=$(pwd)
for dot_directory in ${dot_directories[@]}; do
if [ -d $HOME/"."$dot_directory ]; then
mv $HOME/"."$dot_directory $current_path"/backups/"$timestamp$dot_directory
fi
echo "Setting up "$dot_directory
ln -s $current_path/$dot_directory $HOME/"."$dot_directory
done
}
# Begin Main
install_vim_plug
setup_dotfiles
setup_dot_directories