This allows people to incorporate the thoughtbot dotfiles into their own dotfiles in a more fine-grained manner. I left some things in zshrc that we should eventually handle more precisely: - Load `.zsh/functions/*`. This could instead be replaced with: `mv .zsh/functions/* .zsh/configs`. - Load `.aliases`. This could instead be replaced with: `mv .aliases .zsh/configs/aliases.zsh`. - Load `.zshrc.local`. This file can realistically go away entirely, with people adding their own files to `.zsh/configs`. A further refactoring, which I have done locally, is to introduce a `~/.sh/configs` directory, in which people can put POSIX-specific configuration that can be shared between GNU Bash, zsh, ksh, etc: aliases, functions, paths, prompts, and so on. But one step at a time. Other changes: * Move aliases setup to occur after loading other config, as some of our aliases depend on environment variables having been set, so alias loading must come last after we've sourced `zsh/configs`. * Move autocompletion for `g` function from the function definition to to `zsh/completions/_g` * Move `PATH` setup to `zsh/configs/post` to ensure it happens after other configuration that might alter the `PATH`
46 lines
960 B
Bash
46 lines
960 B
Bash
# load custom executable functions
|
|
for function in ~/.zsh/functions/*; do
|
|
source $function
|
|
done
|
|
|
|
# extra files in ~/.zsh/configs/pre , ~/.zsh/configs , and ~/.zsh/configs/post
|
|
# these are loaded first, second, and third, respectively.
|
|
_load_settings() {
|
|
_dir="$1"
|
|
if [ -d "$_dir" ]; then
|
|
if [ -d "$_dir/pre" ]; then
|
|
for config in "$_dir"/pre/**/*(N-.); do
|
|
. $config
|
|
done
|
|
fi
|
|
|
|
for config in "$_dir"/**/*(N-.); do
|
|
case "$config" in
|
|
"$_dir"/pre/*)
|
|
:
|
|
;;
|
|
"$_dir"/post/*)
|
|
:
|
|
;;
|
|
*)
|
|
if [ -f $config ]; then
|
|
. $config
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [ -d "$_dir/post" ]; then
|
|
for config in "$_dir"/post/**/*(N-.); do
|
|
. $config
|
|
done
|
|
fi
|
|
fi
|
|
}
|
|
_load_settings "$HOME/.zsh/configs"
|
|
|
|
# aliases
|
|
[[ -f ~/.aliases ]] && source ~/.aliases
|
|
|
|
# Local config
|
|
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
|