I can get working the tool grc
which allows to have colors for permissions and different colors as a function of the size of files listed for example with ls -l
command.
On my previous MacBook with High Sierra 10.13.6, I show you an example of what I get :
As you can see, I have a colors code for the different sizes of files (increasingly white, yellow, green and red).
Now, on my new MacBook with Mojave 10.14.6, with the same ~/.bashrc
and ~/.bash_profile
files, I can't have the same rendering than for the High Sierra 10.13.6 MacBook pro. Here below what I get :
You can see that no colors appear for size files (unlike the High Sierra case).
I get the same issue when I do a ssh from Mojave to High Sierra.
Here the content of ~/.bashrc
on Mojave not working version :
############ dircolors binary #################
export PATH=/opt/local/libexec/gnubin:$PATH
###############################################
export CLICOLOR=1
export LS_COLORS='README*=4;31:*.txt=1;35'
eval `dircolors ~/.dircolors`
########### GRC colourify #################
source ~/.grc/grc_bash
########### alias l #######################
alias l='grc -es --colour=auto ls --color -G -lrt'
########## function ls ####################
function ls { grc -es --colour=auto ls --color -G -C -rt "$@" | gsed -r 's/'$(echo -e "\033")'\[[0-9]{1,2}(;([0-9]{1,2})?)?[mK]//g' ;}
For ~/.grc/grc_bash
, I have put :
GRC="$(which grc)"
if [ "$TERM" != dumb ] && [ -n "$GRC" ]; then
alias colourify="$GRC -es --colour=auto"
alias blkid='colourify blkid'
alias nmap='colourify nmap'
alias configure='colourify ./configure'
alias df='colourify df'
alias diff='colourify diff'
alias docker='colourify docker'
alias docker-machine='colourify docker-machine'
alias du='colourify du'
alias env='colourify env'
alias free='colourify free'
alias fdisk='colourify fdisk'
alias findmnt='colourify findmnt'
alias make='colourify make'
alias gcc='colourify gcc'
alias g++='colourify g++'
alias id='colourify id'
alias ip='colourify ip'
alias iptables='colourify iptables'
alias as='colourify as'
alias gas='colourify gas'
alias ld='colourify ld'
alias ls='colourify ls'
alias lsof='colourify lsof'
alias lsblk='colourify lsblk'
alias lspci='colourify lspci'
alias netstat='colourify netstat'
alias ping='colourify ping'
alias traceroute='colourify traceroute'
alias traceroute6='colourify traceroute6'
alias head='colourify head'
alias tail='colourify tail'
alias dig='colourify dig'
alias mount='colourify mount'
alias ps='colourify ps'
alias mtr='colourify mtr'
alias semanage='colourify semanage'
alias getsebool='colourify setsebool'
alias ifconfig='colourify ifconfig'
fi
with ~/.grc/grc.conf
:
(^|[/\w\.]+/)semanage fcontext\s?
conf.semanagefcontext
(^|[/\w\.]+/)semanage (user|login|port)\s?
conf.semanageuser
# getsebool
(^|[/\w\.]+/)getsebool\s?
conf.getsebool
# ulimit
(^|[/\w\.]+/)ulimit\s?
conf.ulimit
# vmstat
(^|[/\w\.]+/)vmstat\s?
conf.vmstat
# dnf
(^|[/\w\.]+/)dnf\s?
conf.dnf
# nmap
(^|[/\w\.]+/)nmap\s?
conf.nmap
# uptime | w
(^|[/\w\.]+/)(uptime|w)\s?
conf.uptime
# getfacl
(^|[/\w\.]+/)getfacl\s?
conf.getfacl
# showmount
(^|[/\w\.]+/)showmount\s?
conf.showmount
# apache ant command
(^|[/\w\.]+/)ant\s?
conf.ant
# # apache maven command
(^|[/\w\.]+/)mvn\s?
conf.mvn
At first sight, where could error come from ? Maybe I have forgotten an environment variable or an unsupported option for ls -lrt
that would prevent the colors code for size of files …
Any remark is welcome, Regards
UPDATE 1:
As you can see, I did a :
|fab@astro|14:03:19|~/temp| alias l
alias l='grc -es --colour=auto ls --color -G -lrt'
which shows exactly the alias for command "l
"
From the screen cpature below, the I realized that I have no group name following normally following the name of owner (due to -G
flag). @klanomath
, Relatively to your screen capture and example, do you think my issue comes from this missing field ?
Indee, on your screen capture, you have a name of group, it may produce missing colors with grc and its regexp used by default ?
Best Answer
The size coloring function of the gcr ls command is still working with Mojave. You've changed the date format in the shell from month/day/(year)/time (US) to day/month/(year)/time (mostly Europe) though.
Now the day (1-31) will be colored with the default "size" color (black in my example and white in your example) as all sizes below 1M.
So either return to the US date format, or modify the respective regex expression(s) in conf.ls.
Proof:
US:
Europe:
To get different colors for smaller sizes (i.e. sizes below 1M) I added the following lines to grc's conf.ls file (the regular expressions below aren't really worked out properly - the alternative way to detect the size pattern (
|\d(?:[,.]?\d+)?[K]
) isn't correct, so don't just copy & paste them - but they work for the example screenshots:The exemplary regular expression
regexp=\s+(\d{5}|\d+(?:[,.]?\d+)?[K])(?=\s[A-Z][a-z]{2}\s)
means the following:\s+(\d{5}|\d+(?:[,.]?\d+)?[K])
: search for a pattern with 1 or more non-printing characters, 5 digits (eg 34249) or 1 or more digits followed by an optional , or ., more optional digits and a K (e.g. 10K or 13.1K)which must be followed by
(?=...)
:\s[A-Z][a-z]{2}\s
which is the pattern for an abbreviated month surrounded by one non-printing character on each side(e.g. Oct )With the european date format active the condition won't be fulfilled because the day (one or two digits) follows after the file size. Instead the day and month would meet the requirements, if a day had five digits.
Here is a conf.ls which should work with the all french locale in Mojave's terminal. I added some working date coloring because the (french) month apparently changed to all lowercase in Mojave. You can simply remove size coloring for smaller file sizes by deleting the respective lines or change colors if you don't like them.
Example screenshot: