Skip to content

Commit

Permalink
Add os-specific fragment file directories
Browse files Browse the repository at this point in the history
Make it easier to have fragment files that are only sourced on a
specific OS.

Signed-off-by: Joe Block <[email protected]>
  • Loading branch information
unixorn committed Oct 5, 2023
1 parent 9c31f27 commit 87b970b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
- [Customizing with ~/.zshrc.d](#customizing-with-zshrcd)
- [I like a plugin, but some of the aliases and functions it installs overwrite other commands or aliases I use](#i-like-a-plugin-but-some-of-the-aliases-and-functions-it-installs-overwrite-other-commands-or-aliases-i-use)
- [ZSH options](#zsh-options)
- [Fragment file directories](#fragment-file-directories)
- [Self-update Settings](#self-update-settings)
- [Customizing the plugin list](#customizing-the-plugin-list)
- [Using fragment files](#using-fragment-files)
Expand Down Expand Up @@ -341,9 +342,15 @@ Once you've cleared all the unwanted aliases and functions, you can add new ones

The quickstart kit does an opinionated (i.e., my way) setup of ZSH options and adds some functions and aliases I like on my systems.

However, `~/.zshrc.d` is processed *after* the quickstart sets its aliases, functions, and ZSH options, so if you don't care for something as set up in the quickstart, you can override the offending item in a shell fragment file there.
#### Fragment file directories

The kit also looks for files in `~/.zshrc.pre-plugins.d`, and you can use snippet files in there to set environment variables that alter the startup behavior of plugins.
You can customize the quickstart by adding files to its `zshrc.d` directories.

After the quickstart sets up its aliases, functions, plugins and ZSH options, it will source every fragment file in `~/.zshrc.d`.

If you want to set variables _before_ the quickstart starts setup to alter behavior, stick your fragment files in `~/.zshrc.pre-plugins.d`.

To make it easier to have macOS or Linux-specific settings tweaks, the quickstart also supports os-specific pre & post `.zshrc.d` directories. If you want a file to only be sourced on a single os, the quickstart also checks for `.zshrc.pre-plugins.$(uname).d` and `~/.zshrc.$(uname).d` during loading.

### Self-update Settings

Expand Down
8 changes: 8 additions & 0 deletions zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,10 @@ fi
mkdir -p ~/.zshrc.pre-plugins.d
load-shell-fragments ~/.zshrc.pre-plugins.d

if [[ -d "~/.zshrc.pre-plugins.$(uname).d" ]]; then
load-shell-fragments "~/.zshrc.pre-plugins.$(uname).d"
fi

# macOS doesn't have a python by default. This makes the omz python and
# zsh-completion-generator plugins sad, so if there isn't a python, alias
# it to python3
Expand Down Expand Up @@ -618,6 +622,10 @@ fi
mkdir -p ~/.zshrc.d
load-shell-fragments ~/.zshrc.d

if [[ -d "~/.zshrc.$(uname).d" ]]; then
load-shell-fragments "~/.zshrc.$(uname).d"
fi

# If GOPATH is defined, add it to $PATH
if [[ -n "$GOPATH" ]]; then
if [[ -d "$GOPATH" ]]; then
Expand Down

0 comments on commit 87b970b

Please sign in to comment.