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.
9 if [ x$DEBUG != x ]; then
15 source_debug "sourcing ~/.shell/env"
18 # Use UTF-8 encoding in the terminal. Don't use LC_ALL as it's used for
19 # debugging purposes. Thanks to twb in Freenode/#screen (2009-10-02 10:25).
23 # Add ~/bin and ~/.bin to PATH if available.
27 if [ -d ~/.bin ]; then
35 # Set less as pager, its configuration is done through the .less file.
39 # Use ~/tmp as directory for temporary files if available to reduce security
40 # problems on multi-user systems.
41 if [ -O ~/tmp -a -d ~/tmp ]; then
45 export TMP TEMP TMPDIR
48 # Set colors for GNU ls (and zsh completions).
49 # See `dircolors --print-database` for possible colors.
51 LS_COLORS=$LS_COLORS':fi=00' # normal files: normal
52 LS_COLORS=$LS_COLORS':di=34;01' # directories: blue bold
53 LS_COLORS=$LS_COLORS':ln=36' # symbolic links: cyan
54 LS_COLORS=$LS_COLORS':pi=00' # named pipes: normal
55 LS_COLORS=$LS_COLORS':so=00' # sockets: normal
56 LS_COLORS=$LS_COLORS':bd=00' # block devices: normal
57 LS_COLORS=$LS_COLORS':cd=00' # character devices: normal
58 LS_COLORS=$LS_COLORS':or=36;41' # orphaned links: red background
59 LS_COLORS=$LS_COLORS':su=31;01;43' # setuid files: yellow background
60 LS_COLORS=$LS_COLORS':sg=31;01;43' # setgid files: yellow background
61 LS_COLORS=$LS_COLORS':ow=34;01;41' # directories writable by others: blue background
62 LS_COLORS=$LS_COLORS':ex=31;01' # executables: bold red
64 # Set the same colors for non GNU ls, except for orphaned links which aren't
66 LSCOLORS='ExgxxxxxBxxxxxBdBdExEb'
67 # ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
68 # | | | | | | | | | | |
69 # | | | | | | | | | | *- directory writable to others, without sticky bit
70 # | | | | | | | | | *--- directory writable to others, with sticky bit
71 # | | | | | | | | *----- executable with setgid bit set
72 # | | | | | | | *------- executable with setuid bit set
73 # | | | | | | *--------- character special
74 # | | | | | *----------- block special
75 # | | | | *------------- executable
76 # | | | *--------------- pipe
77 # | | *----------------- socket
78 # | *------------------- symbolic link
79 # *--------------------- directory
83 # Sources a configuration file if it exists; loads a fallback .local file if
84 # it doesn't. If the .local files doesn't exist nothing is sourced.
86 # $1: Path to directory where configuration files are located.
87 # $2: Directory name in $1 where the non .local files are stored, can be
88 # empty. If empty both configuration files (normal and .local) are stored
90 # $3: Base name of file in $2, for example "rc" or "env".
91 # $4: Extension for $3, if this file doesn't exist "$1/$3.local" is sourced.
92 # Can be empty, then no extension is used.
93 # $5: Additional options, set to nolocal to prevent loading of "$1/$3.local"
94 # if "$1/$2/$3.$4" doesn't exist.
96 # Example with the following directory/file structure, $os is Darwin and
97 # $hostname is marvin.
104 # ~/.zsh/host/rc.marvin
105 # ~/.zsh/os/rc.Darwin
107 # To load additional rc files from within ~/.zsh/rc use the following:
109 # source_config ~/.zsh os rc $os # loads os/rc.Darwin
110 # source_config ~/.zsh host rc $hostname # loads host/rc.marvin
112 # To load additional env files from within ~/.zsh/env use the following (note
113 # nolocal to prevent loading env.local two times if os and host files don't
116 # source_config zsh os env $os nolocal # loads os/rc.Darwin
117 # source_config zsh host env $hostname # loads env.local
119 # By letting $4 empty normal configuration files can be sourced. A .local can
122 # source_config zsh "" file # loads zsh/file if it exists
124 # Doesn't fit perfectly in this file, but this is the best place to make it
125 # available everywhere.
127 # If DEBUG is set to a non empty value additional debug output is printed.
129 # Path to the file to source and its local counterpart.
130 if [ x$4 != x ]; then
131 source_file=$1/$2/$3.$4
132 # If $4 is empty don't append a trailing dot. This allows source_config()
133 # to load normal configuration files.
137 source_file_local=$1/$3.local
139 # Additional debug output.
140 source_debug "source_config(): checking if $source_file exists"
141 source_debug "source_config(): checking if $source_file_local exists"
143 # If the file does exist then source it.
144 if [ -f $source_file ]; then
145 source_debug "source_config(): -> sourcing $source_file"
148 # Otherwise load the .local file if it exists and .local files are
150 elif [ -f $source_file_local -a x$5 != xnolocal ]; then
151 source_debug "source_config(): -> sourcing $source_file_local"
154 source_debug "source_config(): -> neither exists"
157 unset source_file source_file_local
160 source_debug "finished sourcing ~/.shell/env"