perf: improve zsh load speed

This commit is contained in:
2025-08-15 01:57:19 +03:00
parent 2805fef40a
commit 38d15f6820
3 changed files with 73 additions and 29 deletions

42
.zshrc
View File

@@ -1,3 +1,23 @@
# NOTE profiling code
# typeset -gA __t_start __t_end
# setstartk() { __t_start[$1]=$EPOCHREALTIME; }
# setendk() { __t_end[$1]=$EPOCHREALTIME; }
# outputmsk() { # key [label...]
# local k=$1; shift
# float ms=$(( ( ${__t_end[$k]:-0} - ${__t_start[$k]:-0} ) * 1000.0 ))
# if [[ -n $* ]]; then
# printf "%s %.2fms\n" "$*" "$ms"
# else
# printf "%.2f\n" "$ms"
# fi
# }
#
# setstartk zshrc
# export PROFILING_MODE=1
# if [ $PROFILING_MODE -ne 0 ]; then
# zmodload zsh/zprof
# fi
export DOTFILES="$HOME/.dotfiles"
export CFG="$DOTFILES/.config"
export DOTBIN="$HOME/.config/bin"
@@ -5,7 +25,7 @@ export DOTBIN_META="$HOME/.config/.bin"
# Load sofmani-managed zsh plugins
setopt +o nomatch
for plugin in ~/.local/share/zsh/plugins/**/**/*.plugin.zsh; do
for plugin in ~/.local/share/zsh/plugins/**/*.plugin.zsh; do
[ -e "$plugin" ] && source "$plugin"
done
source ~/.local/share/zsh/plugins/powerlevel10k/powerlevel10k.zsh-theme
@@ -47,22 +67,22 @@ bindkey "^[[1;3D" backward-word
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
export HIST_STAMPS="%d/%m/%Y %I:%M:%S"
export HIST_FIND_NO_DUPS=true
setopt histignoredups
# export HIST_STAMPS="%d/%m/%Y %I:%M:%S"
# export HIST_FIND_NO_DUPS=true
# setopt histignoredups
# Preferred editor for local and remote sessions
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='nvim'
else
export EDITOR='nvim'
fi
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='nvim'
# else
# export EDITOR='nvim'
# fi
export VISUAL="$EDITOR"
tmux source-file "$HOME/.config/tmux/conf.tmux" 2>/dev/null
# tmux source-file "$HOME/.config/tmux/conf.tmux" 2>/dev/null
source "$DOTFILES/exports.zsh" # must run before zsh_init
source "$DOTFILES/aliases.zsh"
[[ ! -f "$HOME/.config/.p10k.zsh" ]] || source "$HOME/.config/.p10k.zsh"

View File

@@ -29,7 +29,6 @@ alias l="ls -A"
alias v="nvim ."
alias vi="nvim"
alias vim="nvim"
alias nvim="nvim"
alias lvim="nvim -c':e#<1'"
alias serve="open http://localhost:\${PORT:-3001} & http-server -p \${PORT:-3001}"

View File

@@ -9,10 +9,6 @@ export GITHUB_GPG_KEY_ID="B5690EEEBB952194"
# local bin
export PATH="$HOME/.local/bin:$HOME/bin:/usr/local/bin:/usr/local/sbin:$PATH"
# Atuin
export PATH="$HOME/.atuin/bin:$PATH"
eval "$(atuin init zsh)"
# local plugins
export PLUGINS_DIR="$HOME/.local/share/zsh/plugins"
export TMUX_PLUGINS_DIR="$HOME/.tmux/plugins"
@@ -58,9 +54,22 @@ fi
# yamllint
export YAMLLINT_CONFIG_FILE="$HOME/.config/.yamllint.yml"
# Atuin
export PATH="$HOME/.atuin/bin:$PATH"
eval "$(atuin init zsh)"
# atuin() {
# unset -f atuin
# eval "$(command atuin init zsh)"
# atuin "$@"
# }
# FNM
if [[ -f $(which fnm) ]]; then
eval "$(fnm env --use-on-cd)"
fnm() {
unset -f fnm
eval "$(command fnm env)"
fnm "$@"
}
fi
# SurrealDB
@@ -70,7 +79,11 @@ fi
# Node
if [[ -f $(which npm) ]]; then
export PATH="$(npm get prefix -g)/bin:$PATH"
npm() {
unset -f npm
export PATH="$(npm get prefix -g)/bin:$PATH"
npm "$@"
}
fi
# PNPM
@@ -82,14 +95,15 @@ esac
if [[ -f $(which pnpm) ]]; then
export PATH="$PNPM_HOME:$PATH"
export PATH=$(pnpm bin --global):$PATH
export PATH="$HOME/Library/pnpm:$PATH"
# export PATH=$(pnpm bin --global):$PATH
fi
# Yarn
if [[ -f $(which yarn) ]]; then
export PATH="$HOME/.yarn/bin:$PATH"
export PATH="$HOME/.config/yarn/global/node_modules/.bin:$PATH"
fi
# if [[ -f $(which yarn) ]]; then
# export PATH="$HOME/.yarn/bin:$PATH"
# export PATH="$HOME/.config/yarn/global/node_modules/.bin:$PATH"
# fi
# Ruby
if [[ -f $(which ruby) ]]; then
@@ -102,8 +116,13 @@ fi
if [[ -d "$HOME/.pyenv" ]]; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
pyenv() {
unset -f pyenv
eval "$(command pyenv init -)"
eval "$(command pyenv virtualenv-init -)"
pyenv "$@"
}
fi
# Gcloud
@@ -137,9 +156,9 @@ if [[ ! -z $DOTBIN ]]; then
fi
# Rust cargo
if [[ -f "$HOME/.cargo/env" ]]; then
. "$HOME/.cargo/env"
fi
# if [[ -f "$HOME/.cargo/env" ]]; then
# . "$HOME/.cargo/env"
# fi
if [[ -d "$HOME/Dev/gba/butano" ]]; then
export BUTANO_HOME="$HOME/Dev/gba/butano"
@@ -157,7 +176,13 @@ if [[ -f $(which direnv) ]]; then
fi
if [[ -f ~/.fzf.zsh ]]; then source ~/.fzf.zsh; fi
if [[ -f $(which rbenv) ]]; then eval "$(rbenv init - zsh)"; fi
if [[ -f $(which rbenv) ]]; then
rbenv() {
unset -f rbenv
eval "$(command rbenv init - zsh)"
rbenv "$@"
}
fi
export SHELLCHECK_OPTS='--shell=bash'
export DOCKER_CLI_HINTS=false