Based in KIAaze answer, I came up with my custom modification:
(Done in Ubuntu 14.04 with coreutils 8.21)
Install: (no change) -- be sure you have deb-src repositories enabled --
sudo apt-get build-dep coreutils
apt-get source coreutils
cd coreutils-8.21
(Keep a note on which packages were installed during the "build-dep coreutils" command, you will need them to clean up at the end).
Code modifications: (patch available here)
Added: "C_EXEC_HARDLINK" and "em":
enum indicator_no
{
C_LEFT, C_RIGHT, C_END, C_RESET, C_NORM, C_FILE, C_DIR, C_LINK,
C_FIFO, C_SOCK,
C_BLK, C_CHR, C_MISSING, C_ORPHAN, C_EXEC, C_DOOR, C_SETUID, C_SETGID,
C_STICKY, C_OTHER_WRITABLE, C_STICKY_OTHER_WRITABLE, C_CAP,
C_MULTIHARDLINK, C_EXEC_HARDLINK, C_CLR_TO_EOL
};
static const char *const indicator_name[]=
{
"lc", "rc", "ec", "rs", "no", "fi", "di", "ln", "pi", "so",
"bd", "cd", "mi", "or", "ex", "do", "su", "sg", "st",
"ow", "tw", "ca", "mh", "em", "cl", NULL
};
Set default color:
static struct bin_str color_indicator[] =
{
{ LEN_STR_PAIR ("\033[") }, /* lc: Left of color sequence */
{ LEN_STR_PAIR ("m") }, /* rc: Right of color sequence */
{ 0, NULL }, /* ec: End color (replaces lc+no+rc) */
{ LEN_STR_PAIR ("0") }, /* rs: Reset to ordinary colors */
{ 0, NULL }, /* no: Normal */
{ 0, NULL }, /* fi: File: default */
{ LEN_STR_PAIR ("01;34") }, /* di: Directory: bright blue */
{ LEN_STR_PAIR ("01;36") }, /* ln: Symlink: bright cyan */
{ LEN_STR_PAIR ("33") }, /* pi: Pipe: yellow/brown */
{ LEN_STR_PAIR ("01;35") }, /* so: Socket: bright magenta */
{ LEN_STR_PAIR ("01;33") }, /* bd: Block device: bright yellow */
{ LEN_STR_PAIR ("01;33") }, /* cd: Char device: bright yellow */
{ 0, NULL }, /* mi: Missing file: undefined */
{ 0, NULL }, /* or: Orphaned symlink: undefined */
{ LEN_STR_PAIR ("01;32") }, /* ex: Executable: bright green */
{ LEN_STR_PAIR ("01;35") }, /* do: Door: bright magenta */
{ LEN_STR_PAIR ("37;41") }, /* su: setuid: white on red */
{ LEN_STR_PAIR ("30;43") }, /* sg: setgid: black on yellow */
{ LEN_STR_PAIR ("37;44") }, /* st: sticky: black on blue */
{ LEN_STR_PAIR ("34;42") }, /* ow: other-writable: blue on green */
{ LEN_STR_PAIR ("30;42") }, /* tw: ow w/ sticky: black on green */
{ LEN_STR_PAIR ("30;41") }, /* ca: black on red */
{ 0, NULL }, /* mh: HardLink: disabled by default */
{ 0, NULL }, /* em: Executable HardLink: disabled by default */
{ LEN_STR_PAIR ("\033[K") }, /* cl: clear to end of line */
};
You can set your custom colors either above or in your .bashrc script like this:
export LS_COLORS="ln=01;36:mh=01;36:em=01;33";
see: What do the different colors mean in the terminal?
Set the priority rule:
{
type = C_FILE;
if ((mode & S_ISUID) != 0 && is_colored (C_SETUID))
type = C_SETUID;
else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))
type = C_SETGID;
else if (is_colored (C_CAP) && f->has_capability)
type = C_CAP;
else if ((1 stat.st_nlink) && (mode & S_IXUGO) != 0 && is_colored (C_EXEC_HARDLINK))
type = C_EXEC_HARDLINK;
else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
type = C_EXEC;
else if ((1 stat.st_nlink) && is_colored (C_MULTIHARDLINK))
type = C_MULTIHARDLINK;
}
Then compile: (command must be run as user, not root)
debuild -us -uc -b
You can run the above command several times as it will clean the compilation each time (in case you want to do your own customizations).
(as stated by KIAaze, it may return an error at the end related to a test, but the "ls" command works fine).
Finally, we replace "ls":
sudo mv /bin/ls /bin/ls.orig
sudo mv src/ls /bin/ls
Cleaning up:
cd ..
rm -rf coreutils*
sudo apt-get remove <list of packages installed by 'build-dep coreutils'>
ls
, eg the BSDls
(I looked at thebusybox
, LS_COLORS isn't implemented). But you will probably have to compile anotherls
from source anyway, if you already know the change you need to make, why not just do this to the GNU one?