Improve shell start-up time by lazy-loading various tools

This commit is contained in:
2020-04-26 21:59:25 +01:00
parent 4f4ac73ca3
commit ab88f2cb66
4 changed files with 72 additions and 33 deletions

View File

@@ -7,5 +7,9 @@ alias hl="helm"
alias mk="minikube" alias mk="minikube"
if (( $+commands[kubectl] )); then if (( $+commands[kubectl] )); then
eval "$(kubectl completion zsh)" # lazy-load kubectl setup
_kubectl() {
unset -f _kubectl
eval "$(command kubectl completion zsh)"
}
fi fi

View File

@@ -3,6 +3,4 @@
# #
# Ensure 256 color support in Linux # Ensure 256 color support in Linux
if [[ "$(uname)" == "Linux" ]]; then export TERM="xterm-256color"
export TERM="xterm-256color"
fi

View File

@@ -50,32 +50,51 @@ alias bo="bundle open"
alias bp="bundle package" alias bp="bundle package"
alias bu="bundle update" alias bu="bundle update"
# lazy-load rbenv if (( $+commands[rbenv] )); then
rbenv() { # lazy-load rbenv
eval "$(command rbenv init -)" rbenv() {
rbenv "$@" load-rbenv
} rbenv "$@"
}
rbenv-each-version () { _rbenv() {
local current_version="$RBENV_VERSION" load-rbenv
_rbenv "$@"
}
for v in $(ls "${HOME}/.rbenv/versions"); do compctl -K _rbenv rbenv
echo "==> Ruby $v:"
export RBENV_VERSION="$v"
eval $*
done
export RBENV_VERSION="$current_version" load-rbenv() {
} unset -f load-rbenv _rbenv rbenv
eval "$(command rbenv init -)"
}
# lunchy auto-completion rbenv-each-version () {
if which gem &> /dev/null && gem which lunchy &> /dev/null; then local current_version="$RBENV_VERSION"
LUNCHY_DIR="$(dirname `gem which lunchy`)/../extras"
if [ -f "$LUNCHY_DIR/lunchy-completion.zsh" ]; then for v in $(ls "${HOME}/.rbenv/versions"); do
. "$LUNCHY_DIR/lunchy-completion.zsh" echo "==> Ruby $v:"
fi export RBENV_VERSION="$v"
eval $*
done
export RBENV_VERSION="$current_version"
}
fi fi
# lazy-load lunchy auto-completation
_lunchy() {
unset -f _lunchy
local lunchy_dir
if which gem &> /dev/null && gem which lunchy &> /dev/null; then
lunchy_dir="$(dirname `gem which lunchy`)/../extras"
if [ -f "${lunchy_dir}/lunchy-completion.bash" ]; then
source "${lunchy_dir}/lunchy-completion.bash"
fi
fi
_lunchy "$@"
}
# Solargraph related commands # Solargraph related commands
solargraph-install () { solargraph-install () {

View File

@@ -12,19 +12,37 @@ fi
# Tmuxifier # Tmuxifier
if [ -d "$DOTFILES/tmux/tmuxifier" ]; then if [ -d "$DOTFILES/tmux/tmuxifier" ]; then
if [ -d "$DOTPFILES/tmux-layouts" ]; then
export TMUXIFIER_LAYOUT_PATH="$DOTPFILES/tmux-layouts"
else
export TMUXIFIER_LAYOUT_PATH="$HOME/.tmux-layouts"
fi
path_prepend "$DOTFILES/tmux/tmuxifier/bin"
eval "$(tmuxifier init -)"
alias m="tmuxifier" alias m="tmuxifier"
alias ms="tmuxifier load-session" alias ms="tmuxifier load-session"
alias mw="tmuxifier load-window" alias mw="tmuxifier load-window"
alias mm="tmuxifier load-session main" alias mm="tmuxifier load-session main"
# lazy-load tmuxifier
tmuxifier() {
load-tmuxifier
tmuxifier "$@"
}
_tmuxifier() {
load-tmuxifier
_tmuxifier "$@"
}
compctl -K _tmuxifier tmuxifier
load-tmuxifier() {
# unset lazy-load functions
unset -f load-tmuxifier _tmuxifier tmuxifier
if [ -d "$DOTPFILES/tmux-layouts" ]; then
export TMUXIFIER_LAYOUT_PATH="$DOTPFILES/tmux-layouts"
else
export TMUXIFIER_LAYOUT_PATH="$HOME/.tmux-layouts"
fi
path_prepend "$DOTFILES/tmux/tmuxifier/bin"
eval "$(command tmuxifier init -)"
}
fi fi
use-tmuxifier-dev() { use-tmuxifier-dev() {