-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap
executable file
·52 lines (45 loc) · 1.35 KB
/
bootstrap
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
#!/bin/bash
cd "$(dirname $0)"
git pull
git submodule init
git submodule update
# Clean out any outdated symlinks from ~
for file in $(ls -A ~); do
# If $file
# - is a symlink
# - that points to a nonexistent file
# - somewhere inside this directory
# Then rm it
[[ -h ~/$file ]] && [[ ! -e ~/$file ]] && [[ $(ls -l ~/$file) == *$(pwd)* ]] && rm ~/$file
done
# Add all the latest symlinks into ~
for file in $(ls -A | grep -v "^\.skipfiles$" | grep -vf .skipfiles); do
if [[ -e ~/$file ]] && [[ ! -h ~/$file ]]; then
echo "skipping ~/$file, as it already exists"
else
ln -fs $(pwd)/$file ~/
fi
done
cd - >/dev/null
# Install prezto
if type zsh>/dev/null 2>&1; then
if [[ -d "${ZDOTDIR:-$HOME}/.zprezto" ]]; then
cd "${ZDOTDIR:-$HOME}/.zprezto"
git pull && git submodule update --init --recursive
cd - >/dev/null
else
git clone --recursive https://github.com/jcamenisch/prezto.git "${ZDOTDIR:-$HOME}/.zprezto"
fi
for script in $(ls ${ZDOTDIR:-$HOME}/.zprezto/runcoms/); do
if [[ ! "$script" =~ '.' ]]; then
src=${ZDOTDIR:-$HOME}/.zprezto/runcoms/$script
dest=$HOME/.$script
if [[ -e $dest ]]; then
[[ "$src" == "$(readlink $dest)" ]] || echo "not linking $dest to $src, since it has been customized at $(readlink $dest)"
else
ln -s $src $dest
fi
fi
done
fi
source ~/.profile