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 GNU 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), orphaned links with red background (or), setuid (su) and setgid
20 # (sg) files with yellow background, directories writable by others with blue
21 # background (ow) and executables bold red (ex).
22 # See `dircolors --print-database` for possible colors.
23 LS_COLORS="no=00:fi=00:di=34;01:ln=36:pi=00:so=00:bd=00:cd=00:\
24 or=36;41:su=31;01;43:sg=31;01;43:ow=34;01;41:ex=31;01"
26 # Set the same colors for non GNU ls, except for orphaned links which aren't
28 LSCOLORS='ExgxxxxxBxxxxxBdBdExEb'
29 # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
30 # | | | | | | | | | | |
31 # | | | | | | | | | | *- directory writable to others, without sticky bit
32 # | | | | | | | | | *--- directory writable to others, with sticky bit
33 # | | | | | | | | *----- executable with setgid bit set
34 # | | | | | | | *------- executable with setuid bit set
35 # | | | | | | *--------- character special
36 # | | | | | *----------- block special
37 # | | | | *------------- executable
38 # | | | *--------------- pipe
39 # | | *----------------- socket
40 # | *------------------- symbolic link
41 # *--------------------- directory
45 # Sources a configuration file if it exists; loads a fallback .local file if
46 # it doesn't. If the .local files doesn't exist nothing is sourced.
48 # $1: Path to directory where configuration files are located.
49 # $2: Directory name in $1 where the non .local files are stored, can be
50 # empty. If empty both configuration files (normal and .local) are stored
52 # $3: Base name of file in $2, for example "rc" or "env".
53 # $4: Extension for $3, if this file doesn't exist "$1/$3.local" is sourced.
54 # $5: Additional options, set to nolocal to prevent loading of "$1/$3.local"
55 # if "$1/$2/$3.$4" doesn't exist.
57 # Example with the following directory/file structure, $os is Darwin and
58 # $hostname is marvin.
65 # ~/.zsh/host/rc.marvin
68 # To load additional rc files from within ~/.zsh/rc use the following:
70 # source_config ~/.zsh os rc $os # loads os/rc.Darwin
71 # source_config ~/.zsh host rc $hostname # loads host/rc.marvin
73 # To load additional env files from within ~/.zsh/env use the following (note
74 # nolocal to prevent loading env.local two times if os and host files don't
77 # source_config zsh os env $os nolocal # loads os/rc.Darwin
78 # source_config zsh host env $hostname # loads env.local
80 # Doesn't fit perfectly in this file, but this is the best place to make it
81 # available everywhere.
82 function source_config() {
83 # Path to the file to source and its local counterpart.
84 local source_file=$1/$2/$3.$4
85 local source_file_local=$1/$3.local
87 # Additional debug output.
88 if [ x$DEBUG != x ]; then
89 echo "source_config(): checking if $source_file exists"
90 echo "source_config(): checking if $source_file_local exists"
93 # If the file does exist then source it.
94 if [ -f $source_file ]; then
95 if [ x$DEBUG != x ]; then
96 echo "source_config(): sourcing $source_file"
100 # Otherwise load the .local file if it exists and .local files are
102 elif [ -f $source_file_local -a x$5 != xnolocal ]; then
103 if [ x$DEBUG != x ]; then
104 echo "source_config(): sourcing $source_file_local"
106 source $source_file_local