summaryrefslogtreecommitdiff
path: root/.zshrc
blob: 76538039318158d0467dcb584b905a817b1fcab3 (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
##
## THIS FILE IS NOT INTENDED TO BE MODIFIED ! READ ABOVE...
##
#
# Instead, add/edit your configuration files inside $ZDOTDIR.
#
# If you want to add a file, name it specifically in the form
#
# 	$ZDOTDIR/??_*.zsh
#
# Where "??" should be a two-digit number.
# With that, file ``10_Toto.zsh'' would be parsed before
# file ``20_Tutu.zsh'', allowing you ordering your scripts.
# 
# If you want to make host-specific configurations, create a
# file named with the root of your configuration file, and
# append to it ".$(hostname -s)". (replace "zsh" by the hostname.
# if you have a computer named "zsh", well....... :-) )
# For example, for specific configuration for the host HAL in
# the file 10_Toto.zsh, you would create a file named 10_Toto.HAL
#

ZDOTDIR=${ZDOTDIR:-~/.zsh}
mkdir -p $ZDOTDIR

# Useful environment variables which may be used
# at any time - We compute them now to avoid calling
# the required processes each time we'll need.
USER=${USER:-`whoami`}
UID=${UID:-`id -u`}
HOST=${HOST:-$(hostname -s)}
DOMAIN=${DOMAIN:-${$(hostname -d 2>&-):-$(hostname -y 2>&-)}}

DEBUG=no

export USER HOST DOMAIN UID

if [ -d $ZDOTDIR ]; then
	for script in $ZDOTDIR/??_*.zsh
	do

        [ "$DEBUG" = "yes" ] && echo "${${script:t:r}/??_/}... ";
		source $script

        for i in "net:$DOMAIN" "host:$HOST" "user:$USER" "user:$SUDO_USER"
        do
            specific_script=${script:h}/$i/${${script:t}/??_/}
            if test -f $specific_script
			then
        		[ "$DEBUG" = "yes" ] && echo "$i/${${specific_script:t:r}/??_/}... ";
				source $specific_script
			fi
        done
	done
fi

if privileged_user
then
	[ "`pwd`" = ~ ] && cd ~root
	export HOME=~root
fi