summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyren223 <ulmliad223@gmail.com>2024-09-19 14:17:02 +0300
committerKyren223 <ulmliad223@gmail.com>2024-09-19 14:17:02 +0300
commitfde857bb38223a7fd1c90127cf06bb23c93bb37a (patch)
tree59a5e62d589bd8f8411aaa17f2b7e9e04f9867a8
parent70c2c1d5c3327201bb784bb63c00ffa821fdd494 (diff)
feat(zshrc): completely overhauled zshrc to reduce startup time
-rw-r--r--.zshrc123
1 files changed, 62 insertions, 61 deletions
diff --git a/.zshrc b/.zshrc
index 43ac1f9..f561ba5 100644
--- a/.zshrc
+++ b/.zshrc
@@ -1,63 +1,62 @@
# Fix for tmux on openSuse with WSL2
export TMUX_TMPDIR='/tmp'
-# Directory to store zinit and plugins
-ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
+# Enable rustup tab completion for zsh - https://rust-lang.github.io/rustup/installation/index.html
+rustup completions zsh > ~/.zfunc/_rustup
+fpath+=~/.zfunc
-# Download zinit if it doesn't exist yet
-if [ ! -d "$ZINIT_HOME" ]; then
- mkdir -p "$(dirname $ZINIT_HOME)"
- git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
+# Install zinit if missing
+if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then
+ print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f"
+ command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit"
+ command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \
+ print -P "%F{33} %F{34}Installation successful.%f%b" || \
+ print -P "%F{160} The clone has failed.%f%b"
fi
-# Load zinit
-source "${ZINIT_HOME}/zinit.zsh"
+# Load Zinit
+source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
+autoload -Uz _zinit
+(( ${+_comps} )) && _comps[zinit]=_zinit
# Zsh plugins
-zinit light zsh-users/zsh-syntax-highlighting
-zinit light zsh-users/zsh-completions
+zinit ice wait lucid && zinit light zsh-users/zsh-syntax-highlighting
+zinit ice wait lucid && zinit light zsh-users/zsh-completions
+zinit ice wait lucid && zinit light Aloxaf/fzf-tab
+zinit ice wait lucid atload'_zsh_autosuggest_start'
zinit light zsh-users/zsh-autosuggestions
-zinit light Aloxaf/fzf-tab
# Zsh snippets
-zinit snippet OMZP::git
-zinit snippet OMZP::sudo
-zinit snippet OMZP::kubectl
-zinit snippet OMZP::kubectx
-zinit snippet OMZP::command-not-found
-
-# Enable rustup tab completion for zsh - https://rust-lang.github.io/rustup/installation/index.html
-fpath+=~/.zfunc
-
-# Load completions
-autoload -Uz compinit && compinit
+zinit ice wait lucid && zinit snippet OMZP::git
+zinit ice wait lucid && zinit snippet OMZP::sudo
+zinit ice wait lucid && zinit snippet OMZP::kubectl
+zinit ice wait lucid && zinit snippet OMZP::kubectx
+zinit ice wait lucid && zinit snippet OMZP::command-not-found
-zinit cdreplay -q
-
-# Setup hooks for VIMODE in zsh
-function zle-keymap-select {
-if [[ ${KEYMAP} == vicmd ]]; then
- export VIMODE="NORMAL"
- echo -ne '\e[2 q'
-else
- export VIMODE="INSERT"
- echo -ne '\e[6 q'
-fi
-}
-
-function zle-line-init {
-export VIMODE="INSERT"
-echo -ne '\e[6 q'
-}
-
-function zle-line-finish {
-export VIMODE="INSERT"
-echo -ne '\e[6 q'
-}
-
-zle -N zle-keymap-select
-zle -N zle-line-init
-zle -N zle-line-finish
+# # Setup hooks for VIMODE in zsh
+# function zle-keymap-select {
+# if [[ ${KEYMAP} == vicmd ]]; then
+# export VIMODE="NORMAL"
+# echo -ne '\e[2 q'
+# else
+# export VIMODE="INSERT"
+# echo -ne '\e[6 q'
+# fi
+# }
+#
+# function zle-line-init {
+# export VIMODE="INSERT"
+# echo -ne '\e[6 q'
+# }
+#
+# function zle-line-finish {
+# export VIMODE="INSERT"
+# echo -ne '\e[6 q'
+# }
+#
+# zle -N zle-keymap-select
+# zle -N zle-line-init
+# zle -N zle-line-finish
# Keybindings
bindkey -v
@@ -84,15 +83,24 @@ zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu no
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza $realpath'
-zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'eza $realpath'
+zstyle ':fzf-tab:complete:__zoxide_z:*' fzf-preview 'ls $realpath'
# Load Homebrew
-eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
+zinit ice wait lucid atload' eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"'
+zinit load zdharma-continuum/null
# Shell integrations
-source <(fzf --zsh)
-eval "$(zoxide init --cmd cd zsh)"
-eval "$(oh-my-posh init zsh --config $HOME/.config/ohmyposh/tokyocat_laptop.omp.yml)"
+zinit ice wait lucid atload'eval "$(oh-my-posh init zsh --config $HOME/.config/ohmyposh/tokyocat.omp.yml)"'
+zinit load zdharma-continuum/null
+
+zinit ice wait'!' nocd lucid atload'_omp_precmd'
+zinit load zdharma-continuum/null
+
+zinit ice wait lucid atload"source <(fzf --zsh)"
+zinit load zdharma-continuum/null
+
+zinit ice wait lucid atload'eval "$(zoxide init --cmd cd zsh)"'
+zinit load zdharma-continuum/null
# Aliases
alias nvim='nvim.sh'
@@ -104,16 +112,8 @@ alias c='clear'
alias q='exit'
alias ':q'='exit'
alias vim='nvim'
-alias python='~/python/venv/bin/python'
-alias pip='~/python/venv/bin/pip'
-alias vi='nvim $(fzf --preview="bat --style=numbers --color=always --line-range :500 {}")'
alias sqlite3='sqlite3 --box'
-alias zshrc='vim ~/.zshrc && source ~/.zshrc'
-alias tmuxconf='vim ~/.config/tmux/tmux.conf'
-alias nvimconf='cd ~/.config/nvim && nvim'
-alias vimrc='nvimconf'
-
alias ivm='vim'
alias dc='cd'
@@ -126,6 +126,7 @@ alias gc='git commit'
alias gp='git push'
alias gP='git pull'
alias gl='git log --oneline -n 10'
+alias gd='git diff'
# Exports
export PATH="$HOMEBREW_PREFIX/opt/ncurses/bin:$PATH"