From 1e976efb21acb4a4e1046dd97e89307bba5e6baf Mon Sep 17 00:00:00 2001 From: zachir Date: Sat, 19 Jul 2025 22:43:50 -0500 Subject: Add optimization to zsh loading It requires using ZDOTDIR again --- zsh/.zshenv | 7 +++++ zsh/.zshrc | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ zsh/zshenv | 7 ----- zsh/zshrc | 96 --------------------------------------------------------- 4 files changed, 107 insertions(+), 103 deletions(-) create mode 100644 zsh/.zshenv create mode 100644 zsh/.zshrc delete mode 100644 zsh/zshenv delete mode 100644 zsh/zshrc (limited to 'zsh') diff --git a/zsh/.zshenv b/zsh/.zshenv new file mode 100644 index 0000000..3719ef4 --- /dev/null +++ b/zsh/.zshenv @@ -0,0 +1,7 @@ +# ZSH SPECIFIC CONFIGS +unset HISTFILE +export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" +export skip_global_compinit=1 +fpath=($XDG_CONFIG_HOME/functions $fpath) +[ -f /etc/profile ] && . /etc/profile +[ -f "$XDG_CONFIG_HOME/sh/profile" ] && . "$XDG_CONFIG_HOME/sh/profile" diff --git a/zsh/.zshrc b/zsh/.zshrc new file mode 100644 index 0000000..791b5d1 --- /dev/null +++ b/zsh/.zshrc @@ -0,0 +1,100 @@ +#zmodload zsh/zprof +if [ -n "$ZPLUG_HOME" ]; then + if [ -d "$ZPLUG_HOME" ]; then + export ZPLUG_INSTALLED="y" + source "$ZPLUG_HOME/init.zsh" + fi +elif [ -d "$XDG_DATA_HOME/zplug" ]; then + export ZPLUG_INSTALLED="y" + source "$XDG_DATA_HOME/zplug/init.zsh" +elif [ -d "$HOME/.zplug" ]; then + export ZPLUG_INSTALLED="y" + source "$HOME/.zplug/init.zsh" +fi +[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config" +HISTFILE="$XDG_CONFIG_HOME/zsh/hist" +SAVEHIST=1000 +HISTSIZE=1000 +setopt APPEND_HISTORY +setopt HIST_FIND_NO_DUPS +setopt HIST_EXPIRE_DUPS_FIRST +setopt HIST_VERIFY +setopt HIST_IGNORE_DUPS +setopt INC_APPEND_HISTORY +setopt HIST_REDUCE_BLANKS +setopt COMPLETE_ALIASES +setopt AUTO_CD + +_SH="zsh" + +if [ -f "$XDG_CONFIG_HOME"/sh/aliases ]; then + source "$XDG_CONFIG_HOME"/sh/aliases +fi +if [ -f "$XDG_CONFIG_HOME"/sh/functions ]; then + source "$XDG_CONFIG_HOME"/sh/functions +fi + +if [ -f "$XDG_CONFIG_HOME/zsh/zshrc" ]; then + alias e='source "$XDG_CONFIG_HOME/zsh/zshrc"' +elif [ -f "$XDG_CONFIG_HOME/zshrc" ]; then + alias e='source "$XDG_CONFIG_HOME/zshrc"' +elif [ -f "$HOME"/.zshrc ]; then + alias e='source ~/.zshrc' +fi + +source ~/.config/zsh/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE} + +#autoload zkbd; zkbd +bindkey -v +bindkey "${key[Backspace]}" backward-delete-char +bindkey "${key[Delete]}" delete-char +bindkey "${key[Home]}" beginning-of-line +bindkey "${key[End]}" end-of-line +bindkey "${key[PageUp]}" history-substring-search-up +bindkey "${key[PageDown]}" history-substring-search-down + +if (env | grep -Fq 'DISTROBOX'); then + MYPROMPT=$'%F{000}%K{004}[%n@%m]%F{013}\UE0B2%K{013}%F{000}%~%F{013}%K{004}\UE0B0%F{000}%#%F{004}%k\UE0B0%f ' +else + MYPROMPT=$'%F{000}%K{002}[%n@%m]%F{006}\UE0B2%K{006}%F{000}%~%F{006}%K{002}\UE0B0%F{000}%#%F{002}%k\UE0B0%f ' +fi +function zle-line-init zle-keymap-select { + VIM_PROMPT=$'%F{000}%K{012}[%n@%m]%F{006}\UE0B2%K{006}%F{000}%~%F{006}%K{012}\UE0B0%F{000}%#%F{012}%k\UE0B0%f ' + PS1="${${KEYMAP/vicmd/$VIM_PROMPT}/main/$MYPROMPT}" + zle reset-prompt +} + +zle -N zle-line-init +zle -N zle-keymap-select +export KEYTIMEOUT=1 + +#fpath+="$XDG_CONFIG_HOME/zsh/zfunc" + +if [ -n "$ZPLUG_INSTALLED" ]; then + # zsh history substring search + zplug "zsh-users/zsh-history-substring-search", as:plugin + + bindkey "${key[Up]}" history-substring-search-up + bindkey "${key[Down]}" history-substring-search-down + bindkey -M vicmd "${key[Up]}" history-substring-search-up + bindkey -M vicmd "${key[Down]}" history-substring-search-down + bindkey -M vicmd "k" history-substring-search-up + bindkey -M vicmd "j" history-substring-search-down + + # zsh syntax highlighting + zplug "zsh-users/zsh-syntax-highlighting", defer:2 + + # load zsh plugins + zplug load +fi + +autoload -Uz compinit +if [[ -n ${ZDOTDIR}/.zcompdump(#qN.mh+24) ]]; then + compinit +else + compinit -C; +fi; + +zstyle ':completion:*' hosts off + +#zprof diff --git a/zsh/zshenv b/zsh/zshenv deleted file mode 100644 index 3719ef4..0000000 --- a/zsh/zshenv +++ /dev/null @@ -1,7 +0,0 @@ -# ZSH SPECIFIC CONFIGS -unset HISTFILE -export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" -export skip_global_compinit=1 -fpath=($XDG_CONFIG_HOME/functions $fpath) -[ -f /etc/profile ] && . /etc/profile -[ -f "$XDG_CONFIG_HOME/sh/profile" ] && . "$XDG_CONFIG_HOME/sh/profile" diff --git a/zsh/zshrc b/zsh/zshrc deleted file mode 100644 index 09a5e32..0000000 --- a/zsh/zshrc +++ /dev/null @@ -1,96 +0,0 @@ -#zmodload zsh/zprof -if [ -n "$ZPLUG_HOME" ]; then - if [ -d "$ZPLUG_HOME" ]; then - export ZPLUG_INSTALLED="y" - source "$ZPLUG_HOME/init.zsh" - fi -elif [ -d "$XDG_DATA_HOME/zplug" ]; then - export ZPLUG_INSTALLED="y" - source "$XDG_DATA_HOME/zplug/init.zsh" -elif [ -d "$HOME/.zplug" ]; then - export ZPLUG_INSTALLED="y" - source "$HOME/.zplug/init.zsh" -fi -[ -z "$XDG_CONFIG_HOME" ] && XDG_CONFIG_HOME="$HOME/.config" -HISTFILE="$XDG_CONFIG_HOME/zsh/hist" -SAVEHIST=1000 -HISTSIZE=1000 -setopt APPEND_HISTORY -setopt HIST_FIND_NO_DUPS -setopt HIST_EXPIRE_DUPS_FIRST -setopt HIST_VERIFY -setopt HIST_IGNORE_DUPS -setopt INC_APPEND_HISTORY -setopt HIST_REDUCE_BLANKS -setopt COMPLETE_ALIASES -setopt AUTO_CD - -_SH="zsh" - -if [ -f "$XDG_CONFIG_HOME"/sh/aliases ]; then - source "$XDG_CONFIG_HOME"/sh/aliases -fi -if [ -f "$XDG_CONFIG_HOME"/sh/functions ]; then - source "$XDG_CONFIG_HOME"/sh/functions -fi - -if [ -f "$XDG_CONFIG_HOME/zsh/zshrc" ]; then - alias e='source "$XDG_CONFIG_HOME/zsh/zshrc"' -elif [ -f "$XDG_CONFIG_HOME/zshrc" ]; then - alias e='source "$XDG_CONFIG_HOME/zshrc"' -elif [ -f "$HOME"/.zshrc ]; then - alias e='source ~/.zshrc' -fi - -source ~/.config/zsh/.zkbd/$TERM-${${DISPLAY:t}:-$VENDOR-$OSTYPE} - -#autoload zkbd; zkbd -bindkey -v -bindkey "${key[Backspace]}" backward-delete-char -bindkey "${key[Delete]}" delete-char -bindkey "${key[Home]}" beginning-of-line -bindkey "${key[End]}" end-of-line -bindkey "${key[PageUp]}" history-substring-search-up -bindkey "${key[PageDown]}" history-substring-search-down - -if (env | grep -Fq 'DISTROBOX'); then - MYPROMPT=$'%F{000}%K{004}[%n@%m]%F{013}\UE0B2%K{013}%F{000}%~%F{013}%K{004}\UE0B0%F{000}%#%F{004}%k\UE0B0%f ' -else - MYPROMPT=$'%F{000}%K{002}[%n@%m]%F{006}\UE0B2%K{006}%F{000}%~%F{006}%K{002}\UE0B0%F{000}%#%F{002}%k\UE0B0%f ' -fi -function zle-line-init zle-keymap-select { - VIM_PROMPT=$'%F{000}%K{012}[%n@%m]%F{006}\UE0B2%K{006}%F{000}%~%F{006}%K{012}\UE0B0%F{000}%#%F{012}%k\UE0B0%f ' - PS1="${${KEYMAP/vicmd/$VIM_PROMPT}/main/$MYPROMPT}" - zle reset-prompt -} - -zle -N zle-line-init -zle -N zle-keymap-select -export KEYTIMEOUT=1 - -fpath+="$XDG_CONFIG_HOME/zsh/zfunc" - -if [ -n "$ZPLUG_INSTALLED" ]; then - # zsh history substring search - zplug "zsh-users/zsh-history-substring-search", as:plugin - - bindkey "${key[Up]}" history-substring-search-up - bindkey "${key[Down]}" history-substring-search-down - bindkey -M vicmd "${key[Up]}" history-substring-search-up - bindkey -M vicmd "${key[Down]}" history-substring-search-down - bindkey -M vicmd "k" history-substring-search-up - bindkey -M vicmd "j" history-substring-search-down - - # zsh syntax highlighting - zplug "zsh-users/zsh-syntax-highlighting", defer:2 - - # load zsh plugins - zplug load -fi - -autoload -Uz compinit -compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION" - -zstyle ':completion:*' hosts off - -#zprof -- cgit v1.2.3