Terminal does not source .zshrc with custom colors for ls and cd command
The problem is in the order the files are sourced. LS_COLORS
must be defined before you run zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
.
You can fix this by renaming the files to something like 00theme-and-appearance.zsh
and 01completion.zsh
.
Related videos on Youtube
JJD
Android, Kotlin, Java, Git, Python, Ruby, Ruby on Rails, JavaScript, MacOS, Ubuntu #SOreadytohelp http://stackoverflow.com/10m
Updated on September 18, 2022Comments
-
JJD over 1 year
I customized the directory and file colors for
ls
andcd
+TAB
. Here is my configuration.
My configuration
My system environment.
Ubuntu 10.10 zsh 4.3.10 (x86_64-unknown-linux-gnu) oh-my-zsh // http://git://github.com/robbyrussell/oh-my-zsh.git Terminal
My .zshrc in $HOME.
// .zshrc echo "Sourcing $0." ZSH=$HOME/.oh-my-zsh ZSH_THEME="josh" source $ZSH/oh-my-zsh.sh
A custom zsh script in ~/.oh-my-zsh/custom/completion.zsh
// completion.zsh echo "Sourcing $0." # Same completion colors when using cd as with ls. zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} zstyle ':completion:*:*:*:*:*' menu yes select
A custom zsh script in ~/.oh-my-zsh/custom/theme-and-appearance.zsh
// theme-and-appearance.zsh echo "Sourcing $0." export LS_COLORS='di=1;34:ln=35:so=32:pi=0;33:ex=32:bd=34;46:cd=34;43:su=0;41:sg=0;46:tw=1;34:ow=1;34:'
The problem description.
When I open the Terminal for the first time 3 files are sourced. Notice, that
.zshrc
does appear but not with its path nor file name.Sourcing zsh. Sourcing /home/john/.oh-my-zsh/custom/completion.zsh. Sourcing /home/john/.oh-my-zsh/custom/theme-and-appearance.zsh.
Using the
ls
command the directory listing looks as expected. Though, when I use thecd
command andTAB
for autocompletion directory colors are not the same as withls
.Then I source the configuration once again. Notice, this time
.zshrc
does appear with its full path and file name. I am not sure whether this contributes to the problem explained here.$ . ~/.zshrc Sourcing /home/john/.zshrc. Sourcing /home/john/.oh-my-zsh/custom/completion.zsh. Sourcing /home/john/.oh-my-zsh/custom/theme-and-appearance.zsh.
Now both
ls
andcd
+TAB
use the same colors.
Question
How do I have to change my configuration that the customization is loaded as soon as I open the Terminal application?
-
JJD about 12 yearsDamn. I did not see that. Thank you! Do you know a "nicer" solution besides renaming the files?
-
Arrowmaster about 12 years@JJD If you want to keep it all in separate files then renaming them to start with numbers is a common practice to ensure files load in the correct order.
-
JJD about 12 yearsI thought it could get difficult if dependencies are this way this time but for another case the are the other way around. Then renaming files would no longer help and I would need to extract definitions to another file. Is there something like a forward declaration like in programming languages?