-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·77 lines (55 loc) · 2.2 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
#!/bin/bash
DOTFILESHOME="${ZDOTDIR:-$HOME}"
echo -e 'installing dotfiles...\n'
# make backup folder for old dotfiles
mkdir -p "$DOTFILESHOME"/dotfiles/backup/runcoms
#install prezto (https://github.com/dstibrany/prezto)
echo 'installing prezto'
git submodule update --init --recursive --quiet
for rcfile in "$DOTFILESHOME"/dotfiles/.zprezto/runcoms/*; do
if [ ! "${rcfile##*/}" = "README.md" ]; then
# backup old zsh file, if it exists and is not a symlink
if [ -f "$DOTFILESHOME/.${rcfile##*/}" ] && [ ! -L "$DOTFILESHOME/.${rcfile##*/}" ]; then
mv "$DOTFILESHOME/.${rcfile##*/}" "$DOTFILESHOME"/dotfiles/backup/runcoms
fi
ln -s "$rcfile" "$DOTFILESHOME/.${rcfile##*/}"
fi
done
ln -s "$DOTFILESHOME"/dotfiles/.zprezto/ "$DOTFILESHOME"/.zprezto
# backup and copy all .rc files (eg. bashrc, bash_profile, gitconfig, etc.)
echo "backing up old dotfiles and linking in new ones"
for rcfile in "$DOTFILESHOME"/dotfiles/runcoms/*; do
# backup old dotfile, if it exists
if [ -f "$DOTFILESHOME/.${rcfile##*/}" ] && [ ! -L "$DOTFILESHOME/.${rcfile##*/}" ]; then
mv "$DOTFILESHOME/.${rcfile##*/}" "$DOTFILESHOME"/dotfiles/backup/runcoms
fi
# link new dotfile
ln -s "$rcfile" "$DOTFILESHOME/.${rcfile##*/}"
done
#backup old bin directory
echo "backing up $DOTFILESHOME/bin"
if [ -d "$DOTFILESHOME"/bin ]; then
cp -r "$DOTFILESHOME"/bin "$DOTFILESHOME"/dotfiles/backup
rm -rf "$DOTFILESHOME"/bin
fi
#link new bin directory
echo "linking $DOTFILESHOME/bin"
ln -s "$DOTFILESHOME"/dotfiles/bin "$DOTFILESHOME"/bin
#backup old vim directory
echo "backing up $DOTFILESHOME/.vim"
if [ -d "$DOTFILESHOME"/.vim ]; then
cp -r "$DOTFILESHOME"/.vim "$DOTFILESHOME"/dotfiles/backup
rm -rf "$DOTFILESHOME"/.vim
fi
#link new vim directory
echo "linking $DOTFILESHOME/.vim"
ln -s "$DOTFILESHOME"/dotfiles/vim "$DOTFILESHOME"/.vim
#link iterm directory
echo "linking $DOTFILESHOME/.iterm"
rm -rf "$DOTFILESHOME"/.iterm
ln -s "$DOTFILESHOME"/dotfiles/iterm "$DOTFILESHOME"/.iterm
# compile lesskey file
echo "compiling ~/.lesskey into ~/.less"
lesskey -o "$DOTFILESHOME"/.less -- "$DOTFILESHOME"/.lesskey
unset DOTFILESHOME
echo -e '\n...done installing dotfiles'