Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I use ubuntu 11.04.

Is there a way to set coloring for output after tab completion listing of a cd, ls, or etc. ?

i.e.

myshell@root$ cd ~/user/files/ I hit tab...

myfile myfoo mybar <-- this output is colored?

I hope you enjoyed my diagram.

share|improve this question
    
What exactly should be colored? Do you want files to be colored the same as ls --color would do? Do you want the first one to be colored, then when you press Tab again, the second one to be colored, etc? Something else? –  Mikel Apr 17 '12 at 4:18
add comment

1 Answer

up vote 5 down vote accepted

I don't know if it is in bash (the default shell). It is possible in zsh (a more powerful shell than bash, available on most unices including Ubuntu but often not installed by default).

The first time you run zsh, it will offer to create a configuration file (~/.zshrc) for you. The default configuration is a bit barren, for historical compatibility. For colored completion listings, select 2 to configure the “new completion system”, then 2 again to tune it; in the compinstall menu, select 3 to set styles for displaying completions and 3 then 1 to enable colored completions and finally 2 to use the same colors as ls.

If you prefer setting this up by hand, here are the lines you need in your .zshrc:

zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"
autoload -Uz compinit
compinit

The list-colors style tunes colors on file name completions.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.