Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mattmc3
Last active September 13, 2021 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmc3/08ad63f4d7204e1d15e198eb9ddbb8f0 to your computer and use it in GitHub Desktop.
Save mattmc3/08ad63f4d7204e1d15e198eb9ddbb8f0 to your computer and use it in GitHub Desktop.
ZSH - .zshrc that emulates fish's conf.d and functions dirs
# A minimal .zshrc that uses a .zshrc.d for its content
# load zprof first if we need to profile
[[ ${ZSH_PROFILE_RC:-0} -eq 0 ]] || zmodload zsh/zprof
# helpful profiling aliases
alias zprofrc="ZSH_PROFILE_RC=1 zsh"
alias zbench='for i in $(seq 1 10); do; /usr/bin/time zsh -i -c exit; done'
# source all scripts in a config dir
function src_confd {
local files=("$1"/*.{sh,zsh}(.N))
local f; for f in ${(o)files}; do
# ignore files that begin with a tilde
case ${f:t} in '~'*) continue;; esac
source "$f"
done
}
() {
local confdirs=(
"${ZDOTDIR:-$HOME}/.zshrc.d"
"${ZDOTDIR:-$HOME/.config/zsh}/zshrc.d"
"${ZDOTDIR:-$HOME/.config/zsh}/conf.d"
)
local d; for d in $confdirs; do
[[ -d $d ]] || continue
src_confd $d
done
}
# done profiling
[[ ${ZSH_PROFILE_RC:-0} -eq 0 ]] || { unset ZSH_PROFILE_RC && zprof }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment