98 lines
2.7 KiB
Text
98 lines
2.7 KiB
Text
if [[ -n "${ZSH_DEBUG_STARTUP+1}" ]]; then
|
|
zmodload zsh/zprof
|
|
fi
|
|
|
|
HISTFILE=~/.histfile
|
|
HISTSIZE=10000
|
|
SAVEHIST=10000
|
|
setopt INC_APPEND_HISTORY
|
|
|
|
export EDITOR=nvim
|
|
export MANPAGER='nvim +Man!'
|
|
|
|
setopt PROMPT_SUBST
|
|
PROMPT=$'\n%n@%m %~%(?..%F{red}) %%%f '
|
|
|
|
zstyle :compinstall filename '$HOME/.zshrc'
|
|
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
|
|
zstyle ':completion:*' menu select
|
|
autoload -Uz compinit
|
|
if [[ ! -f ~/.zcompdump || -f ~/.zcompdump(N.mh+24) ]]; then
|
|
compinit
|
|
else
|
|
compinit -C
|
|
fi
|
|
export PATH="$PATH:$HOME/.local/bin"
|
|
export PATH="$PATH:$HOME/.cargo/bin"
|
|
|
|
for file in "$XDG_CONFIG_HOME"/zsh/config/*.zsh(N); do
|
|
[ -r "$file" ] && source "$file"
|
|
done
|
|
|
|
function plugin-compile {
|
|
ZPLUGINDIR=${ZPLUGINDIR:-"$XDG_CONFIG_HOME"/zsh/plugins}
|
|
autoload -U zrecompile
|
|
local f
|
|
for f in "$ZPLUGINDIR"/**/*.zsh{,-theme}(N); do
|
|
zrecompile -pq "$f"
|
|
done
|
|
}
|
|
|
|
function plugin-clone {
|
|
ZPLUGINDIR=${ZPLUGINDIR:-"$XDG_CONFIG_HOME"/zsh/plugins}
|
|
local repo plugdir initfile initfiles=()
|
|
for repo in "$@"; do
|
|
plugdir="$ZPLUGINDIR"/${repo:t}
|
|
initfile=$plugdir/${repo:t}.plugin.zsh
|
|
if [[ ! -d $plugdir ]]; then
|
|
echo "Cloning $repo..."
|
|
git clone -q --depth 1 --recursive --shallow-submodules \
|
|
https://github.com/$repo $plugdir
|
|
fi
|
|
if [[ ! -e $initfile ]]; then
|
|
initfiles=($plugdir/*.{plugin.zsh,zsh-theme,zsh,sh}(N))
|
|
(($#initfiles)) && ln -sf $initfiles[1] $initfile
|
|
fi
|
|
done
|
|
plugin-compile
|
|
}
|
|
|
|
function plugin-source {
|
|
local plugdir
|
|
ZPLUGINDIR=${ZPLUGINDIR:-"$XDG_CONFIG_HOME"/zsh/plugins}
|
|
for plugdir in "$@"; do
|
|
[[ $plugdir = /* ]] || plugdir="$ZPLUGINDIR"/$plugdir
|
|
fpath+=$plugdir
|
|
local initfile=$plugdir/${plugdir:t}.plugin.zsh
|
|
(($+functions[zsh-defer])) && zsh-defer . $initfile || . $initfile
|
|
done
|
|
}
|
|
|
|
function plugin-update {
|
|
ZPLUGINDIR=${ZPLUGINDIR:-"$XDG_CONFIG_HOME"/zsh/plugins}
|
|
local d
|
|
for d in "$ZPLUGINDIR"/*/.git(/); do
|
|
echo "Updating ${d:h:t}..."
|
|
command git -C "${d:h}" pull --ff --recurse-submodules --depth 1 --rebase --autostash
|
|
done
|
|
plugin-compile
|
|
echo "Plugins updated"
|
|
}
|
|
|
|
ZSH_PLUGIN_REPOS=(
|
|
hlissner/zsh-autopair
|
|
zsh-users/zsh-autosuggestions
|
|
zsh-users/zsh-syntax-highlighting # https://github.com/zsh-users/zsh-syntax-highlighting#why-must-zsh-syntax-highlightingzsh-be-sourced-at-the-end-of-the-zshrc-file
|
|
)
|
|
|
|
# Plugin bootstrap
|
|
if [[ ! -d ${ZPLUGINDIR:-"$XDG_CONFIG_HOME"/zsh/plugins} ]]; then
|
|
echo "Bootstraping plugins..."
|
|
plugin-clone "${ZSH_PLUGIN_REPOS[@]}"
|
|
fi
|
|
|
|
plugin-source "${(@)ZSH_PLUGIN_REPOS:t}"
|
|
|
|
if [ -n "${ZSH_DEBUG_STARTUP+1}" ]; then
|
|
zprof
|
|
fi
|