1 # Configuration file for environment related options for all shells.
4 # Helper function to print debug information if $DEBUG is not empty.
6 # Doesn't fit perfectly in this file, but this is the best place to make it
7 # available everywhere.
8 function source_debug() {
9 if [ x$DEBUG != x ]; then
15 # Use UTF-8 encoding in the terminal.
24 # Set less as pager, its configuration is done through the .less file.
28 # Set colors for GNU ls (and zsh completions). This colors files normal (fi),
29 # directories blue bold (di), symbolic links cyan (ln), named pipes normal
30 # (pi), sockets normal (so), block devices normal (bd), character devices
31 # normal (cd), orphaned links with red background (or), setuid (su) and setgid
32 # (sg) files with yellow background, directories writable by others with blue
33 # background (ow) and executables bold red (ex).
34 # See `dircolors --print-database` for possible colors.
35 LS_COLORS="no=00:fi=00:di=34;01:ln=36:pi=00:so=00:bd=00:cd=00:\
36 or=36;41:su=31;01;43:sg=31;01;43:ow=34;01;41:ex=31;01"
38 # Set the same colors for non GNU ls, except for orphaned links which aren't
40 LSCOLORS='ExgxxxxxBxxxxxBdBdExEb'
41 # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
42 # | | | | | | | | | | |
43 # | | | | | | | | | | *- directory writable to others, without sticky bit
44 # | | | | | | | | | *--- directory writable to others, with sticky bit
45 # | | | | | | | | *----- executable with setgid bit set
46 # | | | | | | | *------- executable with setuid bit set
47 # | | | | | | *--------- character special
48 # | | | | | *----------- block special
49 # | | | | *------------- executable
50 # | | | *--------------- pipe
51 # | | *----------------- socket
52 # | *------------------- symbolic link
53 # *--------------------- directory
57 # Sources a configuration file if it exists; loads a fallback .local file if
58 # it doesn't. If the .local files doesn't exist nothing is sourced.
60 # $1: Path to directory where configuration files are located.
61 # $2: Directory name in $1 where the non .local files are stored, can be
62 # empty. If empty both configuration files (normal and .local) are stored
64 # $3: Base name of file in $2, for example "rc" or "env".
65 # $4: Extension for $3, if this file doesn't exist "$1/$3.local" is sourced.
66 # $5: Additional options, set to nolocal to prevent loading of "$1/$3.local"
67 # if "$1/$2/$3.$4" doesn't exist.
69 # Example with the following directory/file structure, $os is Darwin and
70 # $hostname is marvin.
77 # ~/.zsh/host/rc.marvin
80 # To load additional rc files from within ~/.zsh/rc use the following:
82 # source_config ~/.zsh os rc $os # loads os/rc.Darwin
83 # source_config ~/.zsh host rc $hostname # loads host/rc.marvin
85 # To load additional env files from within ~/.zsh/env use the following (note
86 # nolocal to prevent loading env.local two times if os and host files don't
89 # source_config zsh os env $os nolocal # loads os/rc.Darwin
90 # source_config zsh host env $hostname # loads env.local
92 # Doesn't fit perfectly in this file, but this is the best place to make it
93 # available everywhere.
95 # If DEBUG is set to a non empty value additional debug output is printed.
96 function source_config() {
97 # Path to the file to source and its local counterpart.
98 local source_file=$1/$2/$3.$4
99 local source_file_local=$1/$3.local
101 # Additional debug output.
102 source_debug "source_config(): checking if $source_file exists"
103 source_debug "source_config(): checking if $source_file_local exists"
105 # If the file does exist then source it.
106 if [ -f $source_file ]; then
107 source_debug "source_config(): sourcing $source_file"
110 # Otherwise load the .local file if it exists and .local files are
112 elif [ -f $source_file_local -a x$5 != xnolocal ]; then
113 source_debug "source_config(): sourcing $source_file_local"
114 source $source_file_local