-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlocal-install
executable file
·141 lines (118 loc) · 4.02 KB
/
local-install
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
#!/bin/bash
############################
# .make.sh
# This script creates symlinks from the home directory to any desired dotfiles in ~/dotfiles
############################
########## Variables
dir=~/dotfiles # dotfiles directory
olddir=~/dotfiles_old # old dotfiles backup directory
files="aliases bashrc exports fonts functions gitconfig path psqlrc vimrc vim zshrc zpreztorc" # list of files/folders to symlink in homedir
##########
# create dotfiles_old in homedir
echo -n "Creating $olddir for backup of any existing dotfiles in ~ ..."
mkdir -p $olddir
echo "done"
# change to the dotfiles directory
echo -n "Changing to the $dir directory ..."
cd $dir
echo "done"
setup_aliases () {
# move any existing dotfiles in homedir to dotfiles_old directory, then create symlinks from the homedir to any files in the ~/dotfiles directory specified in $files
for file in $files; do
echo "Moving any existing dotfiles from ~ to $olddir"
mv ~/.$file ~/dotfiles_old/
echo "Creating symlink to $file in home directory."
ln -s $dir/$file ~/.$file
done
}
install_vim () {
if which vim >/dev/null; then
echo "vim is already installed, good on you!"
else
sudo apt-get install vim
fi
}
install_git () {
if which git >/dev/null; then
echo "git is already installed, good on you!"
else
sudo apt-get install git
echo
read -p "Seems like it's your first git install, would you like yo setup basic config? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo -n "Please enter your git username: "
read git_username
git config --global user.name $git_username
echo
echo -n "Please enter your git email address: "
read git_useremail
git config --global user.email $git_useremail
echo
echo "Your git config has been setup in ~/.gitconfig"
fi
fi
# Installing diff-so-fancy if needed
if [ ! -d ~/bin/diff-so-fancy ]; then
cd ~/bin
git clone https://github.com/stevemao/diff-so-fancy.git
git config --global core.pager "diff-so-fancy | less --tabs=1,5 -R"
fi
}
install_zsh () {
# Test to see if zshell is installed. If it is:
if [ -f /bin/zsh -o -f /usr/bin/zsh ]; then
# Clone Prezt
if [[ ! -d $dir/.zprezto/ ]]; then
git clone --recursive https://github.com/sorin-ionescu/prezto.git ~/.zprezto
echo "====================================="
echo "Be sure to run the following command:"
echo "setopt EXTENDED_GLOB
for rcfile in \"\${ZDOTDIR:-$HOME}\"/.zprezto/runcoms/^README.md(.N); do
ln -s \"\$rcfile\" \"${ZDOTDIR:-\$HOME}/.\${rcfile:t}\"
done"
echo "====================================="
fi
# Set the default shell to zsh if it isn't currently set to zsh
if [[ ! $(echo $SHELL) == $(which zsh) ]]; then
chsh -s $(which zsh)
fi
else
# If zsh isn't installed, get the platform of the current machine
platform=$(uname);
# If the platform is Linux, try an apt-get to install zsh and then recurse
if [[ $platform == 'Linux' ]]; then
if [ -n "$(command -v yum)" ]; then
sudo yum install zsh
else
sudo apt-get install zsh
fi
install_zsh
# If the platform is OS X, tell the user to install zsh :)
elif [[ $platform == 'Darwin' ]]; then
echo "Please install zsh, then re-run this script!"
exit
fi
fi
}
install_vundle () {
if [[ ! -d $dir/vim/bundle/Vundle.vim ]]; then
git clone https://github.com/gmarik/Vundle.vim.git $dir/vim/bundle/Vundle.vim
fi
vim +PluginInstall +qall
}
install_git
install_vim
install_zsh
install_vundle
read -p "Do you want to setup aliases? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
setup_aliases
fi
if [[ ! -d $dir/vim/backup ]]; then
mkdir $dir/vim/backup
fi
if [[ ! -d $dir/vim/swap ]]; then
mkdir $dir/vim/swap
fi