From f9455044cd37b38056548dc340bb916844cb6b28 Mon Sep 17 00:00:00 2001 From: nirenjan Date: Tue, 22 Jan 2013 10:08:45 -0800 Subject: [PATCH] Add bashrc.lscolors script This file is sourced by .bashrc and exports LSCOLORS (for OS X systems). If the .dircolors file exists in the user's home directory, then it is passed to the dircolors utility (if it exists) and the output is evaluated to configure GNU ls coloring. --- bashrc.lscolors | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 bashrc.lscolors diff --git a/bashrc.lscolors b/bashrc.lscolors new file mode 100755 index 0000000..b21e85d --- /dev/null +++ b/bashrc.lscolors @@ -0,0 +1,55 @@ +#!/bin/bash + +if [[ "`uname`" == *"Darwin"* ]] +then + # OS X uses BSD ls which is relatively restricted compared to + # GNU ls as far as coloring options go. Stick to the basics here. + # LSCOLORS is in pairs (fgcolor, bgcolor) + + # Colorscheme for LSCOLORS (BSD) + # a => black A => dark gray + # b => red B => bold red + # c => green C => bold green + # d => brown D => yellow + # e => blue E => bold blue + # f => magenta F => bold magenta + # g => cyan G => bold cyan + # h => gray H => white + # x => default + + # Ordering for LSCOLORS(BSD) + # 1. directory + # 2. symbolic link + # 3. socket + # 4. pipe + # 5. executable + # 6. block device + # 7. character device + # 8. executable with setuid set + # 9. executable with setguid set + # 10. directory writable by others, with sticky bit + # 11. directory writable by others, without sticky bit + + export LSCOLORS="ExGxbxdxCxegedabagacad" + + # Must use either CLICOLOR=1 or ls -G + export CLICOLOR=1 +fi + +DCFILE="$HOME/.dircolors" + +# We can presume we are on a GNU system, or at the very least, +# a system which has the GNU coreutils installed +if [[ -f $DCFILE ]] && [[ -s $DCFILE ]] +then + if [[ ! -z `which dircolors` ]] + then + eval `dircolors $DCFILE` + elif [[ ! -z `which gdircolors` ]] + then + # OS X with coreutils installed from MacPorts will have + # dircolors installed by default as gdircolors. + eval `gdircolors $DCFILE` + fi +fi +