summary refs log tree commit diff stats
path: root/hooks/post-up/zsh
blob: f4720813cf63118a998da9bf8a72023fbe436ccb (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
#!/usr/bin/env zsh
ZDOTDIR="${XDG_CONFIG_HOME:=~/.config}/zsh"

pushd $ZDOTDIR
for f in z*(-.)
do
	[[ -e .$f ]] || ln $f .$f
done
popd

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

local -a zfiles
zfiles=($ZDOTDIR/zshrc)

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

autoload -U zrecompile

if [[ -f $ZDOTDIR/${HOST%%.*}.zsh ]]; then
	zfiles+=$ZDOTDIR/${HOST%%.*}.zsh
fi
if [[ $OSTYPE == freebsd* ]]; then
	zfiles+=$ZDOTDIR/freebsd.zsh
fi

autoload -Uz compinit
compinit -u -d ~/.cache/zsh/compdump
zrecompile -p -R $ZDOTDIR/.zshrc.zwc $zfiles -- \
	-M ~/.cache/zsh/compdump

if [[ -s $commands[fasd] ]]; then
	if [[ ! -d $ZDOTDIR/functions/fasd ]]; then
		mkdir $ZDOTDIR/functions/fasd
	fi
	if [[ ! -h $ZDOTDIR/functions/fasd/fasd ]]; then
		ln -s =fasd $ZDOTDIR/functions/fasd/fasd
	fi
fi

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

[[ -f ~/.zsh/fasd-data ]] && mv ~/.zsh/fasd-data ~/.cache/zsh/fasd-data
[[ -f ~/.zsh/history ]] && mv ~/.zsh/history ~/.cache/zsh/history