mention from where i got the idea
[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 debug "Starting zsh"
21 # Want to use colors in log output...
22 autoload -U colors && colors
23
24 # Idea copied from https://github.com/hugues/zdotdir/blob/master/zshrc
25 # AUTHOR: Hugues Hiegel <hugues@hiegel.fr>
26 # Most of my config is splitted into files and directories
27 if [ -d ${ZDOTDIR} ]; then
28 for script in ${ZDOTDIR}/??_*.zsh; do
29 debug "Loading ${${script:t:r}/??_/}... " -n
30 source $script
31 debug "$fg_no_bold[green]done"
32 for i in "net:$DOMAIN" \
33 "host:$HOST" \
34 "sys:$OSNAME" \
35 "distri:$DISTRI" \
36 "user:$USER" \
37 "user:$SUDO_USER" \
38 "net:$DOMAIN/host:$HOST" \
39 "net:$DOMAIN/sys:$OSNAME" \
40 "net:$DOMAIN/distri:$DISTRI" \
41 "net:$DOMAIN/user:$USER" \
42 "net:$DOMAIN/user:$SUDO_USER" \
43 "net:$DOMAIN/host:$HOST/sys:$OSNAME" \
44 "net:$DOMAIN/host:$HOST/distri:$DISTRI" \
45 "net:$DOMAIN/host:$HOST/user:$USER" \
46 "net:$DOMAIN/host:$HOST/user:$SUDO_USER" \
47 "net:$DOMAIN/host:$HOST/sys:$OSNAME" \
48 "net:$DOMAIN/host:$HOST/sys:$OSNAME/distri:$DISTRI" \
49 "net:$DOMAIN/host:$HOST/sys:$OSNAME/user:$USER" \
50 "net:$DOMAIN/host:$HOST/sys:$OSNAME/user:$SUDO_USER" \
51 "host:$HOST/sys:$OSNAME" \
52 "host:$HOST/distri:$DISTRI" \
53 "host:$HOST/user:$USER" \
54 "host:$HOST/user:$SUDO_USER" \
55 "host:$HOST/sys:$OSNAME/distri:$DISTRI" \
56 "host:$HOST/sys:$OSNAME/user:$USER" \
57 "host:$HOST/sys:$OSNAME/user:$SUDO_USER"
58 do
59 specific_script=${script:h}/$i/${${script:t}/??_/}
60 #debug "Checking $specific_script... "
61 if [ -r ${specific_script} ]; then
62 debug "Loading $i/${${specific_script:t:r}/??_/}... " -n
63 source ${specific_script}
64 debug "$fg_no_bold[green]done"
65 fi
66 done
67 done
68 fi
69
70 # For sudo shells
71 if [ ! -z "$SUDO_USER" ]; then
72 export HOME=~$USER
73 [ "`pwd`" = ~$SUDO_USER ] && cd
74 fi