4

How to change completion coloring when auto-completing subcommands in bash?enter image description here

For unknown reason, it looks like the completion results are treated by bash as broken symlinks. And it looks really disturbing.

System info:

  • Bash version: 4.4.23(1)-release
  • OS: Manjaro Linux

Edit: I understand that by setting off the colored-stats GNU Readline option in ~/.inputrc the coloring will be turned off altogether:

set colored-stats off

But that would also disable other coloring, such as for directory, when auto-completing.

I think this is weird because the broken-symlink-like coloring happens on my Manjaro Linux box at home, but not my Arch Linux box at work. Both are applied with the same bashrc and inputrc. But I didn't check for other potential difference for now.


Edit again: Pasting my ~/.inputrc for reference:

$include /etc/inputrc
$if mode=emacs
# cycle through possible completions
TAB: menu-complete
# complete until the end of common prefix before cycling through possible completions
set menu-complete-display-prefix on
# show possible completions if more than one completions are possible
set show-all-if-ambiguous on
set show-all-if-unmodified on
# do not duplicate characters after the cursor if they consist partially of possbile completion
set skip-completed-text on
# display colors when doing completion as `ls` does
set colored-stats on
# color tab-completion matched prefix part
set colored-completion-prefix on
# fuck off stty key bindings. (stty -a)
set bind-tty-special-chars off
"\C-w": unix-word-rubout
"\eh": kill-region
"\eH": copy-region-as-kill
"\C-x\'": "\'\'\C-b"
"\C-x`": "``\C-b"
"\C-x\"": "\"\"\C-b"
"\C-x{": "{}\C-b"
"\C-x[": "[]\C-b"
"\C-x(": "()\C-b"
"\C-x0": vi-eWord
"\eF": "\C-x0\C-f"
"\eB": vi-bWord
"\eD": "\e \eF\eh"
$endif 
1
  • I'm trying to understand this as well. My assumption is that something in the way it presents the output is assuming that it's a local file and so is treating it as "missing", but I don't know why yet. It would be good if it just showed them as plain text!
    – IBBoard
    Dec 6, 2018 at 20:51

1 Answer 1

5

Completion coloring for GNU Readline is enabled with colored-stats in .inputrc, like you've mentioned.

The colors are determined by $LS_COLORS, which can be generated with dircolors.

The completion suggestions seem to inherit their colors from the MISSING attribute in ~/.dircolors. Commenting it out (or changing to something less disturbing, e.g. removing 05; to disable blinking) prints the suggestions in default colors. The corresponding entry in $LS_COLORS is ...:mi=03;31:... (an example with ANSI colors 03 and 31).

Similar discussion:
https://bugzilla.redhat.com/show_bug.cgi?id=1648170

References:
https://wiki.archlinux.org/index.php/Readline#Colorized_completion
https://wiki.archlinux.org/index.php/Color_output_in_console#ls
dircolors: modify color settings globaly
https://askubuntu.com/questions/466198/how-do-i-change-the-color-for-directories-with-ls-in-the-console

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .