1 # Configuration file for environment related options for all shells.
4 # Use UTF-8 encoding in the terminal.
12 # Set less as pager, its configuration is done through the .less file.
16 # Set colors for ls (and zsh completions). This colors files normal (fi),
17 # directories blue bold (di), symbolic links cyan (ln), named pipes normal
18 # (pi), sockets normal (so), block devices normal (bd), character devices
19 # normal (cd) and executables bold red (ex).
20 # See `dircolors --print-database` for possible colors.
21 LS_COLORS='no=00:fi=00:di=34;01:ln=36:pi=00:so=00:bd=00:cd=00:ex=31;01'
25 # Sources a configuration file if it exists; loads a fallback .local file if
26 # it doesn't. If the .local files doesn't exist nothing is sourced.
28 # $1: Path to directory where configuration files are located.
29 # $2: Directory name in $1 where the non .local files are stored, can be
30 # empty. If empty both configuration files (normal and .local) are stored
32 # $3: Base name of file in $2, for example "rc" or "env".
33 # $4: Extension for $3, if this file doesn't exist "$1/$3.local" is sourced.
34 # $5: Additional options, set to nolocal to prevent loading of "$1/$3.local"
35 # if "$1/$2/$3.$4" doesn't exist.
37 # Example with the following directory/file structure, $os is Darwin and
38 # $hostname is marvin.
45 # ~/.zsh/host/rc.marvin
48 # To load additional rc files from within ~/.zsh/rc use the following:
50 # source_config ~/.zsh os rc $os # loads os/rc.Darwin
51 # source_config ~/.zsh host rc $hostname # loads host/rc.marvin
53 # To load additional env files from within ~/.zsh/env use the following (note
54 # nolocal to prevent loading env.local two times if os and host files don't
57 # source_config zsh os env $os nolocal # loads os/rc.Darwin
58 # source_config zsh host env $hostname # loads env.local
60 # Doesn't fit perfectly in this file, but this is the best place to make it
61 # available everywhere.
62 function source_config() {
63 # Path to the file to source and its local counterpart.
64 local source_file=$1/$2/$3.$4
65 local source_file_local=$1/$3.local
67 # Additional debug output.
68 if [ x$DEBUG != x ]; then
69 echo "source_config(): checking if $source_file exists"
70 echo "source_config(): checking if $source_file_local exists"
73 # If the file does exist then source it.
74 if [ -f $source_file ]; then
75 if [ x$DEBUG != x ]; then
76 echo "source_config(): sourcing $source_file"
80 # Otherwise load the .local file if it exists and .local files are
82 elif [ -f $source_file_local -a x$5 != xnolocal ]; then
83 if [ x$DEBUG != x ]; then
84 echo "source_config(): sourcing $source_file_local"
86 source $source_file_local