]> ruderich.org/simon Gitweb - config/dotfiles.git/blob - shell/env
Added more color options for ls.
[config/dotfiles.git] / shell / env
1 # Configuration file for environment related options for all shells.
2
3
4 # Use UTF-8 encoding in the terminal.
5 LC_ALL=en_US.UTF-8
6 export LC_ALL
7
8 # Use Vim as editor.
9 EDITOR=vim
10 export EDITOR
11
12 # Set less as pager, its configuration is done through the .less file.
13 PAGER=less
14 export PAGER
15
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"
25 export LS_COLORS
26 # Set the same colors for non GNU ls, except for orphaned links which aren't
27 # supported.
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
42 export LSCOLORS
43
44
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.
47 #
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
51 #     in $1.
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.
56 #
57 # Example with the following directory/file structure, $os is Darwin and
58 # $hostname is marvin.
59 #
60 # ~/.zsh
61 # ~/.zsh/env
62 # ~/.zsh/env.local
63 # ~/.zsh/rc
64 # ~/.zsh/rc.local
65 # ~/.zsh/host/rc.marvin
66 # ~/.zsh/os/rc.Darwin
67 #
68 # To load additional rc files from within ~/.zsh/rc use the following:
69 #
70 # source_config ~/.zsh os   rc $os       # loads os/rc.Darwin
71 # source_config ~/.zsh host rc $hostname # loads host/rc.marvin
72 #
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
75 # exist):
76 #
77 # source_config zsh os   env $os       nolocal # loads os/rc.Darwin
78 # source_config zsh host env $hostname         # loads env.local
79 #
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
86
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"
91     fi
92
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"
97         fi
98         source $source_file
99
100     # Otherwise load the .local file if it exists and .local files are
101     # allowed.
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"
105         fi
106         source $source_file_local
107     fi
108 }