1

In bash, I have colored output set up for commands such as ls. I customized the exact colors used with the LS_COLORS environment variable, since the default ones were kind of ugly.

From what I understand the LS_COLORS variable is also supposed to be used to set the color specs for colored tab completion, but that doesn't seem to work. The colored tab completion continues to use the default color specs.

!!!! I AM NOT ASKING HOW TO GET COLORED COMPLETION !!!!

I already have colored completion by putting bind 'set colored-stats on' in my ~/.bashrc file. I'm asking why the colored completion doesn't obey the customizations set in LS_COLORS. Please don't mark me as a duplicate of https://superuser.com/questions/251107/how-to-get-a-colored-tab-completion is there a way to set coloring for cd tab complete? or something similar.

See the attached screenshot. The top command is when I run ls. The second is when I type ls and hit tab. I also tried setting LSCOLORS environment variable, but no luck. I'm using bash 4.4.19 and my $TERM is "xterm-256color" if thats relevant.

different color for ls and tab completion

edit:

The exact way I'm setting the LS_COLORS variable is by having eval "$(dircolors ~/.dircolors)" in my ~/.bashrc file. The ~/.dircolors is what I customized. This sets my LS_COLOR to the following (which successfully customizes my ls output but not tab completion).

$ echo $LS_COLORS
rs=0:no=00:fi=00:di=38;5;26:ln=target:mh=04:pi=01;33:so=01;35:do=01;35:bd=01;33:cd=01;33:or=01;31:mi=00;31:su=32;04:sg=92;04:ca=36;04:tw=04;38;5;26:ow=00;38;5;26:st=01;38;5;26:ex=01;32:*.tar=38;5;202:*.tgz=38;5;202:*.arc=38;5;202:*.arj=38;5;202:*.taz=38;5;202:*.lha=38;5;202:*.lz4=38;5;202:*.lzh=38;5;202:*.lzma=38;5;202:*.tlz=38;5;202:*.txz=38;5;202:*.tzo=38;5;202:*.t7z=38;5;202:*.zip=38;5;202:*.z=38;5;202:*.Z=38;5;202:*.dz=38;5;202:*.gz=38;5;202:*.lrz=38;5;202:*.lz=38;5;202:*.lzo=38;5;202:*.xz=38;5;202:*.zst=38;5;202:*.tzst=38;5;202:*.bz2=38;5;202:*.bz=38;5;202:*.tbz=38;5;202:*.tbz2=38;5;202:*.tz=38;5;202:*.deb=38;5;202:*.rpm=38;5;202:*.jar=38;5;202:*.war=38;5;202:*.ear=38;5;202:*.sar=38;5;202:*.rar=38;5;202:*.alz=38;5;202:*.ace=38;5;202:*.zoo=38;5;202:*.cpio=38;5;202:*.7z=38;5;202:*.rz=38;5;202:*.cab=38;5;202:*.wim=38;5;202:*.swm=38;5;202:*.dwm=38;5;202:*.esd=38;5;202:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
  • I have eval "$(dircolors ~/.dircolors)" in my bashrc that sets LS_COLOR. The exact value is quite long since I have a lot of customizations (I'll edit my question and add it there). The customizations are working for ls but not for tab completion. I honestly have no idea what could be wrong or how to troubleshoot this. – Cnoor0171 Oct 19 at 19:54
  • Doesn't work for me either. – ilkkachu Oct 19 at 20:31
  • did you export LS_COLORS at all? – rastafile Oct 19 at 20:39
  • @Cnoor0171 well no the way you call it. OK so now that is the problem. Somehow between eval and dircolors the export gets lost. – rastafile Oct 19 at 20:44
  • 1
    @rastafile the dircolors command puts the export automatically. The export is definitely working, because without it the output of ls wouldn't be colored either. – Cnoor0171 Oct 19 at 21:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.