forked from stephenfin/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotstrap.sh
executable file
·63 lines (50 loc) · 1.51 KB
/
dotstrap.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
#!/bin/bash
# create symlinks from the home directory to dotfiles in ~/dotfiles
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
dotfiles="vimrc vim inputrc bashrc bash next_review hgrc gitconfig gitignore tmux.conf"
packages="vim"
# ensure all required packages have been installed
for package in $packages; do
if ! command -v $package >/dev/null 2>&1; then
echo "You need to install $package"
exit 1
fi
done
# download submodules
git submodule update --init --recursive
# backup existing dotfiles
for file in $dotfiles; do
src="$HOME/.$file"
dst="$HOME/.olddot/$(date +%s)/.$file"
mkdir -p "$HOME/.olddot/$(date +%s)"
if [ -e "$src" ]; then
echo "Backing up existing file: .$file"
cp -rf "$src" "$dst"
fi
done
# symlink dotfiles to the home dir, each prefixed by a dot (.)
for file in $dotfiles; do
src="$dir/$file"
dst="$HOME/.$file"
rm -rf "$dst"
ln -s "$src" "$dst"
echo "Created $dst"
done
# symlink configfiles to the home dir
# TODO(stephenfin): Make this generic once we synchronize more config options
src="$dir/config/sublime-text-3/Packages/User"
out="$HOME/.config/sublime-text-3/Packages/"
dst="$out/User"
mkdir -p "$out"
ln -s "$src" "$dst"
echo "Created $dst"
# set vim as default editor
update-alternatives --set editor /usr/bin/vim.basic
# install vim plugins
vim +PluginInstall +qall
# (optional) reload environment
read -p "Reload environment now? [y]es/[n]o " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
exec bash
fi