summary refs log tree commit diff stats
path: root/install
blob: a433631aa1c7b160e4df6e63c6474953c67bee97 (plain)
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
#!/usr/bin/env zsh

target=~/projects/dotfiles
pushd $HOME

setopt EXTENDED_GLOB

if [[ ! -d $target ]]
then
	mkdir -pv $target
fi

if [[ -d ~/Library/LaunchAgents ]]
then
	ln -sf $target/launchagents/* ~/Library/LaunchAgents
fi

if [[ ! -d $target && ${(L)host} =~ prefect ]]
then
	git clone ssh://alan@home.alanpearce.co.uk:22222/~/dotfiles.git
fi

install-dot () {
	if [[ ! -d $1 ]]
	then
		mkdir $1
	fi

	for f in $@[2,-1]
	do
		if [[ ! -e $1$f:t ]]
		then
			ln -sf $f $1$f:t
		fi
	done
}

install-dot $target/.git/hooks/ $target/git-hooks/*
install-dot .emacs.d/ $target/emacs/{init.el{,c},elisp}
install-dot . $target/^install(.) $target/zsh/fasdrc
install-dot .ssh/ $target/ssh/*

ln -sf $target/zsh/environment.zsh .zshenv
ln -sf $target/zsh/interactive.zsh .zshrc
ln -sf $target/zsh/login.zsh .zlogin
ln -sf $target/zsh/logout.zsh .zlogout

if [[ -d projects/dwm ]]
then
	install-dot projects/dwm/ $target/dwm/*
fi

if [[ -x =emacs ]]
then
	emacs --batch --eval '(batch-byte-recompile-directory 0)' ~/.emacs.d/
fi

if [[ ! -d ~/.zsh/cache ]]
then
	mkdir -p ~/.zsh/cache
fi

fasd_cache=~/.zsh/cache/fasd-init-zsh
if [[ ! -s "$fasd_cache" || $target/zsh/functions/fasd -nt "$fasd_cache" ]]; then
	$target/zsh/functions/fasd/fasd --init posix-alias zsh-hook zsh-ccomp zsh-ccomp-install zsh-wcomp zsh-wcomp-install >! "$fasd_cache"
fi

autoload -U zrecompile
local -a zfiles
zfiles=(
	$target/zsh/functions/fasd/fasd
	$fasd_cache
	$target/zsh/interactive.zsh
)
if [[ -f $target/zsh/${HOST%%.*}.zsh ]]; then
	zfiles+=$target/zsh/${HOST%%.*}.zsh
fi
if [[ $OSTYPE == freebsd* ]]; then
	zfiles+=$target/zsh/freebsd.zsh
fi

zrecompile -p -R ~/.zshrc.zwc $zfiles -- \
	-M .zsh/cache/compdump

for fp in $target/zsh/functions/*(/); do
	zrecompile -p $fp $fp/*
done

popd