1 # Configuration file for environment related options for all shells.
4 # Use UTF-8 encoding in the terminal.
13 # Set less as pager, its configuration is done through the .less file.
17 # Set colors for GNU ls (and zsh completions). This colors files normal (fi),
18 # directories blue bold (di), symbolic links cyan (ln), named pipes normal
19 # (pi), sockets normal (so), block devices normal (bd), character devices
20 # normal (cd), orphaned links with red background (or), setuid (su) and setgid
21 # (sg) files with yellow background, directories writable by others with blue
22 # background (ow) and executables bold red (ex).
23 # See `dircolors --print-database` for possible colors.
24 LS_COLORS="no=00:fi=00:di=34;01:ln=36:pi=00:so=00:bd=00:cd=00:\
25 or=36;41:su=31;01;43:sg=31;01;43:ow=34;01;41:ex=31;01"
27 # Set the same colors for non GNU ls, except for orphaned links which aren't
29 LSCOLORS='ExgxxxxxBxxxxxBdBdExEb'
30 # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
31 # | | | | | | | | | | |
32 # | | | | | | | | | | *- directory writable to others, without sticky bit
33 # | | | | | | | | | *--- directory writable to others, with sticky bit
34 # | | | | | | | | *----- executable with setgid bit set
35 # | | | | | | | *------- executable with setuid bit set
36 # | | | | | | *--------- character special
37 # | | | | | *----------- block special
38 # | | | | *------------- executable
39 # | | | *--------------- pipe
40 # | | *----------------- socket
41 # | *------------------- symbolic link
42 # *--------------------- directory
46 # Sources a configuration file if it exists; loads a fallback .local file if
47 # it doesn't. If the .local files doesn't exist nothing is sourced.
49 # $1: Path to directory where configuration files are located.
50 # $2: Directory name in $1 where the non .local files are stored, can be
51 # empty. If empty both configuration files (normal and .local) are stored
53 # $3: Base name of file in $2, for example "rc" or "env".
54 # $4: Extension for $3, if this file doesn't exist "$1/$3.local" is sourced.
55 # $5: Additional options, set to nolocal to prevent loading of "$1/$3.local"
56 # if "$1/$2/$3.$4" doesn't exist.
58 # Example with the following directory/file structure, $os is Darwin and
59 # $hostname is marvin.
66 # ~/.zsh/host/rc.marvin
69 # To load additional rc files from within ~/.zsh/rc use the following:
71 # source_config ~/.zsh os rc $os # loads os/rc.Darwin
72 # source_config ~/.zsh host rc $hostname # loads host/rc.marvin
74 # To load additional env files from within ~/.zsh/env use the following (note
75 # nolocal to prevent loading env.local two times if os and host files don't
78 # source_config zsh os env $os nolocal # loads os/rc.Darwin
79 # source_config zsh host env $hostname # loads env.local
81 # Doesn't fit perfectly in this file, but this is the best place to make it
82 # available everywhere.
84 # If DEBUG is set to a non empty value additional debug output is printed.
85 function source_config() {
86 # Path to the file to source and its local counterpart.
87 local source_file=$1/$2/$3.$4
88 local source_file_local=$1/$3.local
90 # Additional debug output.
91 if [ x$DEBUG != x ]; then
92 echo "source_config(): checking if $source_file exists"
93 echo "source_config(): checking if $source_file_local exists"
96 # If the file does exist then source it.
97 if [ -f $source_file ]; then
98 if [ x$DEBUG != x ]; then
99 echo "source_config(): sourcing $source_file"
103 # Otherwise load the .local file if it exists and .local files are
105 elif [ -f $source_file_local -a x$5 != xnolocal ]; then
106 if [ x$DEBUG != x ]; then
107 echo "source_config(): sourcing $source_file_local"
109 source $source_file_local