ShellColors is an Oh My Zsh plugin that automatically updates your terminal background color based
on the presence of a .shellcolor
file in the current directory or one of its parent directories.
The plugin also provides a command interface to set, unset, and manage the .shellcolor
file.
-
Clone the repository into the custom plugins directory of Oh My Zsh:
git clone https://github.com/SaltedBlowfish/zsh-shellcolor.git ~/.oh-my-zsh/custom/plugins/shellcolors
-
Add
shellcolors
to the list of plugins in your.zshrc
file:plugins=(... shellcolors)
-
Reload your Zsh configuration or restart your terminal session:
source ~/.zshrc
The plugin automatically updates the terminal background when you change directories. It searches
for a .shellcolor
file in the current directory and its parent directories; if none is found, it
uses the default color.
A command interface is provided via the shellcolor
command:
-
Set a random color:
shellcolor set random
This command generates a random low-saturation color, writes it to
.shellcolor
, and updates the background. -
Set a specific color:
shellcolor set #RRGGBB
Replace
#RRGGBB
with your desired hexadecimal color code. -
Unset the custom color:
shellcolor unset
This command removes the
.shellcolor
file and reverts to the default background. -
Add
.shellcolor
to .gitignore:shellcolor gitignore
-
Reshim (refresh) the background:
shellcolor reshim
By default, the plugin uses black (#000000
) as the default background color if no .shellcolor
file is found. To change this, set the DEFAULT_SHELLCOLOR
environment variable in your .zshrc
file:
-
Open your
.zshrc
file:vim ~/.zshrc
-
Add the following line with your desired default color:
export DEFAULT_SHELLCOLOR="#yourdefaultcolor"
-
Save the file and reload your Zsh configuration:
source ~/.zshrc