Allow a .local script to load after mine
[zsh.git] / .zsh / .zshrc
1 # -*- mode: sh;-*-
2 ############
3 #
4 # .zshrc
5 # Written by Joerg Jaspert <joerg@debian.org>
6 #
7 ############
8
9 # Base directory for all plugins, themes, functions, whatever
10 ZSH=${HOME}/.zsh
11
12 debug ()
13 {
14 [[ "${DEBUG}" = "no" ]] && return
15 msg=${1:-""}
16 nl=${2:-""}
17 echo ${nl} "${msg}$reset_color"
18 }
19
20 # May want to use colors in log output...
21 [[ "${DEBUG}" = "no" ]] && autoload -U colors && colors
22 debug "Starting zsh"
23
24 autoload -Uz zrecompile
25 zrecompile -q -p -R ${ZDOTDIR}/.zshrc -- -M ${ZDOTDIR}/var/.zcompdump
26
27 # Idea copied from https://github.com/hugues/zdotdir/blob/master/zshrc
28 # AUTHOR: Hugues Hiegel <hugues@hiegel.fr>
29 # Most of my config is splitted into files and directories
30 if [ -d ${ZDOTDIR} ]; then
31 for script in ${ZDOTDIR}/??_*.zsh; do
32 lscript=${script:t:r}
33 debug "Loading ${lscript/??_/}... " -n
34 zrecompile -q -p -U -R ${script}
35 source $script
36 debug "$fg_no_bold[green]done"
37 for i in "net:$DOMAIN" \
38 "host:$HOST" \
39 "sys:$OSNAME" \
40 "distri:$DISTRI" \
41 "user:$USER" \
42 "user:$SUDO_USER" \
43 "net:$DOMAIN/host:$HOST" \
44 "net:$DOMAIN/sys:$OSNAME" \
45 "net:$DOMAIN/distri:$DISTRI" \
46 "net:$DOMAIN/user:$USER" \
47 "net:$DOMAIN/user:$SUDO_USER" \
48 "net:$DOMAIN/host:$HOST/sys:$OSNAME" \
49 "net:$DOMAIN/host:$HOST/distri:$DISTRI" \
50 "net:$DOMAIN/host:$HOST/user:$USER" \
51 "net:$DOMAIN/host:$HOST/user:$SUDO_USER" \
52 "net:$DOMAIN/host:$HOST/sys:$OSNAME" \
53 "net:$DOMAIN/host:$HOST/sys:$OSNAME/distri:$DISTRI" \
54 "net:$DOMAIN/host:$HOST/sys:$OSNAME/user:$USER" \
55 "net:$DOMAIN/host:$HOST/sys:$OSNAME/user:$SUDO_USER" \
56 "host:$HOST/sys:$OSNAME" \
57 "host:$HOST/distri:$DISTRI" \
58 "host:$HOST/user:$USER" \
59 "host:$HOST/user:$SUDO_USER" \
60 "host:$HOST/sys:$OSNAME/distri:$DISTRI" \
61 "host:$HOST/sys:$OSNAME/user:$USER" \
62 "host:$HOST/sys:$OSNAME/user:$SUDO_USER"
63 do
64 specific_script=${script:h}/$i/${${script:t}/??_/}
65 #debug "Checking $specific_script... "
66 if [ -r ${specific_script} ]; then
67 debug "Loading $i/${${specific_script:t:r}/??_/}... " -n
68 zrecompile -q -p -U -R ${specific_script}
69 source ${specific_script}
70 debug "$fg_no_bold[green]done"
71 fi
72 done
73 if [[ -f ${ZDOTDIR}/${lscript}.zsh.local ]]; then
74 debug "Loading local ${lscript/??_/}... " -n
75 zrecompile -q -p -U -R ${lscript}.zsh.local
76 source ${script}.local
77 debug "$fg_no_bold[green]done"
78 fi
79 done
80 fi
81
82 # For sudo shells
83 if [ ! -z "$SUDO_USER" ]; then
84 export HOME=~$USER
85 [ "`pwd`" = ~$SUDO_USER ] && cd
86 fi
87
88 [[ -f ${ZDOTDIR}/.zshlate ]] && source ${ZDOTDIR}/.zshlate || /bin/true