summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.zshrc41
-rw-r--r--zi.init.zsh88
2 files changed, 129 insertions, 0 deletions
diff --git a/.zshrc b/.zshrc
new file mode 100644
index 0000000..4ab1297
--- /dev/null
+++ b/.zshrc
@@ -0,0 +1,41 @@
+typeset -A ZI
+ZI[HOME_DIR]="${FFILES:-${XDG_CACHE_DIR:-$HOME/.cache}}/zi"
+source "$ZDOTDIR/zi.init.zsh" && zzinit
+
+# Load all of your early custom configurations.
+function {
+local config_file
+for config_file ("$ZDOTDIR"/early/*.zsh(N)); do
+ source "$config_file"
+done
+}
+
+zi light "https://github.com/romkatv/powerlevel10k.git"
+zi snippet "https://github.com/ohmyzsh/ohmyzsh/raw/master/plugins/vi-mode/vi-mode.plugin.zsh"
+zi ice lucid wait has="fzf"
+zi light "https://github.com/Aloxaf/fzf-tab.git"
+zi ice blockf from="cgit.farzat.xyz"
+zi load "dotfiles/my-zsh-completions"
+zi ice lucid wait blockf
+zi load "https://github.com/zsh-users/zsh-completions.git"
+zi ice lucid wait
+zi light "https://github.com/z-shell/F-Sy-H.git"
+zi ice lucid wait as'completion' blockf has'man'
+zi snippet "$ZDOTDIR/resources/completion/_man"
+
+# Load all of your custom configurations.
+function {
+local config_file
+for config_file ("$ZDOTDIR"/halfway/*.zsh(N)); do
+ source "$config_file"
+done
+}
+
+# Load zsh completion.
+autoload -Uz compinit
+compinit
+# Load completions saved by zi till now.
+zi cdreplay -q
+
+# Load powerlevel10k configurations.
+source "$ZDOTDIR/manual/p10k.zsh"
diff --git a/zi.init.zsh b/zi.init.zsh
new file mode 100644
index 0000000..49b86a6
--- /dev/null
+++ b/zi.init.zsh
@@ -0,0 +1,88 @@
+#!/usr/bin/env zsh
+# ZI Loader (Values set: default)
+#
+# https://z.digitalclouds.dev/community/zsh_plugin_standard
+0="${ZERO:-${${0:#$ZSH_ARGZERO}:-${(%):-%N}}}"
+0="${${(M)0:#/*}:-$PWD/$0}"
+
+# https://z.digitalclouds.dev/docs/guides/customization
+local repo="https://github.com/z-shell/zi.git"
+local branch="main"
+local verbose_mode="${verbose_mode:-false}"
+typeset -A ZI
+# Where ZI should create all working directories, e.g.: "~/.zi"
+ZI[HOME_DIR]="${ZI[HOME_DIR]:-${HOME}/.zi}"
+# Where ZI code resides, e.g.: "~/.zi/bin"
+ZI[BIN_DIR]="$ZI[HOME_DIR]/bin"
+# Zsh modules directory
+ZI[ZMODULES_DIR]="$ZI[HOME_DIR]/zmodules"
+# Where ZI cache is, e.g.: "~/.cache/zi"
+ZI[CACHE_DIR]="${ZI[CACHE_DIR]:-$HOME/.cache/zi}"
+# Path to .zcompdump file, with the file included (i.e. its name can be different)
+ZI[ZCOMPDUMP_PATH]="$ZI[CACHE_DIR]/.zcompdump"
+# If set to 1, then mutes some of the ZI warnings, specifically the plugin already registered warning
+ZI[MUTE_WARNINGS]="${ZI[MUTE_WARNINGS]:-0}"
+
+# Clone ZI repository if it doesn't exist
+zzsetup() {
+ [[ $verbose_mode == true ]] && builtin print "(ZI): Checking if ZI (zi.zsh) is available."
+ if [[ ! -f "${ZI[BIN_DIR]}/zi.zsh" ]]; then
+ [[ $verbose_mode == true ]] && builtin print "(ZI): ZI (zi.zsh) is not found. Installing..."
+ builtin print -P "%F{33}▓▒░ %F{160}Installing interactive feature-rich plugin manager (%F{33}z-shell/zi%F{160})%f%b"
+ command mkdir -p "${ZI[BIN_DIR]}" && command chmod -R go-w "${ZI[HOME_DIR]}"
+ command git clone -q --progress --branch "$branch" "$repo" "${ZI[BIN_DIR]}"
+ if [[ -f "${ZI[BIN_DIR]}/zi.zsh" ]]; then
+ [[ $verbose_mode == true ]] && builtin print "(ZI): Installed and ZI (zi.zsh) is found"
+ local git_refs=("$(cd "${ZI[BIN_DIR]}"; command git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit | head -10)")
+ print -P "%F{33}▓▒░ %F{34}Successfully installed %F{160}(%F{33}z-shell/zi%F{160})%f%b"
+ print -P "%F{33}▓▒░ %F{226}Last changes:%f%b"
+ print -P "%F{33}▓▒░ %F{160}%F{33}\n${git_refs}%F{160}%f%b"
+ else
+ print -P "%F{160}▓▒░ The clone has failed…%f%b"
+ print -P "%F{160}▓▒░ %F{33} Please report the issue:%f%b"
+ print -P "%F{160}▓▒░ %F{33} https://github.com/z-shell/zi/issues/new%f%b"
+ return 1
+ fi
+ return 0
+ fi
+}
+
+# If setup is successful or ZI is already installed, then load ZI. Otherwise, not continue and exit.
+zzsource() {
+ [[ $verbose_mode == true ]] && builtin print "(ZI): If (zzsetup) function status code 0, then load ZI."
+ if zzsetup; then
+ [[ $verbose_mode == true ]] && builtin print "(ZI): Loading (zi.zsh)"
+ source "${ZI[BIN_DIR]}/zi.zsh"
+ else
+ [[ $verbose_mode == true ]] && builtin print "(ZI): (zzsetup) function status code 1, not continue and exit."
+ exit 1
+ fi
+}
+
+# Load zi module if built
+zzpmod() {
+ [[ $verbose_mode == true ]] && builtin print "(ZI): Checking for ZI module."
+ if [[ -f "${ZI[ZMODULES_DIR]}/zpmod/Src/zi/zpmod.so" ]]; then
+ [[ $verbose_mode == true ]] && builtin print "(ZI): Loading ZI module."
+ module_path+=( "${ZI[ZMODULES_DIR]}/zpmod/Src" )
+ zmodload zi/zpmod &>/dev/null
+ ZI[ZPMOD_ENABLED]=1
+ fi
+}
+
+# Enable completion (completions should be loaded after zzsource)
+zzcomps() {
+ [[ $verbose_mode == true ]] && builtin print "(ZI): Loading completion… (_zi)"
+ autoload -Uz _zi
+ (( ${+_comps} )) && _comps[zi]=_zi
+ ZI[COMPS_ENABLED]=1
+}
+
+# If ZI is installed, load ZI, enable completion and load zpmod.
+zzinit() {
+ (( ZI[SOURCED] )) && return
+ [[ $verbose_mode == true ]] && builtin print "(ZI): Loading ZI (zi.zsh)"
+ zzsource
+ zzcomps
+ zzpmod
+}