Skip to content

mattmc3/zshrc.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zshrc.d

License works with prezto works with ohmyzsh

Load ZSH config files from a zshrc.d directory

Description

This plugin allows you to source your .zshrc configuration from files in a directory.

So, instead of storing all your configuration settings in a single ~/.zshrc file, you can organize .zsh files in a ${ZDOTDIR:-$HOME}/.zshrc.d directory and this plugin will source them.

If using $ZDOTDIR, this plugin supports using the non-hidden $ZDOTDIR/zshrc.d directory as an alternative, or you can set the $ZSHRCD to specify a custom location.

FAQ

Q: Does this mean I can replace my .zshrc file entirely?

A: No, you will still need a .zshrc file for Zsh to run properly, but you can reduce its contents to just the minimal code required to load this plugin and then use your .zshrc.d directory for everything else.

Q: How can I ensure that my .zsh config files are loaded in the right order?

A: Files are sorted alphabetically by locale, the same as your ls command, so name your files accordingly.

Q: How do I name files if I need them to load first?

A: One method is to prefix any files that have to load first with a numbering scheme (ie: 00-99).

Q: How do I name files if I need them to load last?

A: One method is to prefix any files that have to load last with zz-, or zz01-.

Q: How do I keep a file in my zshrc.d directory, but prevent it from being sourced?

A: Files prefixed with a tilde (~) are skipped by this plugin.

Q: What names can I use for my .zshrc.d directory?

A: ${ZDOTDIR:~}/.zshrc.d, $ZDOTDIR/zshrc.d, $ZDOTDIR/conf.d, and $ZDOTDIR/rc.d are supported by default. If you want a different directory, you should set the $ZSHRCD variable.

Customizing

If you want to use an alternate path, add set the $ZSHRCD variable prior to sourcing this plugin:

ZSHRCD=~/path/to/my/custom/zshrc.d

Installation

Install with a Zsh plugin manager

To install using a Zsh plugin manager, add the following to your .zshrc

  • antidote: antidote install mattmc3/zshrc.d
  • zcomet: zcomet load mattmc3/zshrc.d
  • zgenom: zgenom load mattmc3/zshrc.d
  • znap: znap source mattmc3/zshrc.d

Install manually, without a plugin manager

To install manually, first clone the repo:

git clone https://github.com/mattmc3/zshrc.d ${ZDOTDIR:-~}/.zplugins/zshrc.d

Then, in your .zshrc, add the following line:

source ${ZDOTDIR:-~}/.zplugins/zshrc.d/zshrc.d.zsh

Install for Oh-My-Zsh

To install with Oh-My-Zsh, first clone the repo from an interactive Zsh session:

# make sure your $ZSH_CUSTOM is set
ZSH_CUSTOM=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}

# now, clone the plugin
git clone https://github.com/mattmc3/zshrc.d $ZSH_CUSTOM/plugins/zshrc.d

Then, add the plugin to your Oh-My-Zsh plugins list in your .zshrc

# in your .zshrc, add this plugin to your plugins list
plugins=(... zshrc.d)

Install for Prezto

To install with Prezto, first clone the repo from an interactive Zsh session:

# make sure your $ZPREZTODIR is set
ZPREZTODIR=${ZPREZTODIR:-~/.zprezto}
# clone the repo to a prezto contrib dir
git clone https://github.com/mattmc3/zshrc.d $ZPREZTODIR/contrib/zshrc.d/external
# set up the contrib
echo "source \${0:A:h}/external/zshrc.d.plugin.zsh" > $ZPREZTODIR/contrib/zshrc.d/init.zsh

Then, add the plugin to your Prezto plugins list in .zpreztorc

zstyle ':prezto:load' pmodule \
  ... \
  zshrc.d \
  ...

About

Load config files from a zshrc.d directory

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages