mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
add lazy-loading of setup scripts for commands that aren't used very often
This commit is contained in:
parent
682ae85d81
commit
93efc97f14
2 changed files with 17 additions and 6 deletions
|
@ -15,3 +15,17 @@ command_exists() {
|
||||||
source_if_exists() {
|
source_if_exists() {
|
||||||
[[ -f $1 ]] && source "$1"
|
[[ -f $1 ]] && source "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_before() {
|
||||||
|
local command="$1"
|
||||||
|
local init_command="$2"
|
||||||
|
|
||||||
|
eval "$(cat <<EOF
|
||||||
|
$command() {
|
||||||
|
unfunction $command
|
||||||
|
$init_command
|
||||||
|
$command \$@
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
}
|
||||||
|
|
9
zshrc
9
zshrc
|
@ -19,9 +19,6 @@ for script in "$DOTFILES_DIR"/{functions,path,exports,aliases,oh-my-zsh}.zsh; do
|
||||||
source "$script"
|
source "$script"
|
||||||
done
|
done
|
||||||
|
|
||||||
# rbenv
|
run_before rbenv 'eval "$(rbenv init -)"'
|
||||||
command_exists rbenv && eval "$(rbenv init -)"
|
run_before sdk 'source_if_exists "$SDKMAN_DIR/bin/sdkman-init.sh"'
|
||||||
# sdkman
|
run_before yarn 'source_if_exists "$(yarn global dir)/node_modules/tabtab/.completions/yarn.zsh"'
|
||||||
source_if_exists "$SDKMAN_DIR/bin/sdkman-init.sh"
|
|
||||||
# Yarn completion
|
|
||||||
source_if_exists "/usr/local/lib/node_modules/yarn-completions/node_modules/tabtab/.completions/yarn.zsh"
|
|
||||||
|
|
Loading…
Reference in a new issue