feat(zinit): integrate zinit for improved shell configuration (#1)

This commit was merged in pull request #1.
This commit is contained in:
Tri Vo Khac authored and GitHub committed 2025-04-18 20:50:42 +07:00
1 parent d48d58dcdc
commit aa85f4ff43
18 files changed
+202 -492

No files matched your search

+34 -45
View File
@@ -1,49 +1,38 @@
ZAP_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/zap"
ZAP_SCRIPT="$ZAP_DIR/zap.zsh"
ZAP_BRANCH=release-v1
# install zinit
source $ZDOTDIR/zinit
if [ ! -f $ZAP_SCRIPT ]; then
git clone -b "$ZAP_BRANCH" https://github.com/zap-zsh/zap.git "$ZAP_DIR"
fi
# load remote plugins
zinit wait lucid light-mode id-as depth"1" for \
wintermi/zsh-brew \
hlissner/zsh-autopair \
Aloxaf/fzf-tab \
atinit"zicompinit; zicdreplay -q" \
zdharma-continuum/fast-syntax-highlighting \
atload"_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions
source "$ZAP_SCRIPT"
# load prompt theme
zinit ice as"command" from"gh-r" id-as \
atclone"./starship init zsh > init.zsh; ./starship completions zsh > _starship" \
atpull"%atclone" src"init.zsh"
zinit light starship/starship
remote_plugins=(
zap-zsh/supercharge
zap-zsh/fzf
wintermi/zsh-lsd
wintermi/zsh-fnm
zsh-users/zsh-autosuggestions
zsh-users/zsh-completions
zdharma-continuum/fast-syntax-highlighting
hlissner/zsh-autopair
)
plugins=("${remote_plugins[@]}" "$ZDOTDIR/*")
mac_plugins=(wintermi/zsh-brew)
# load binaries
zinit as"command" wait lucid light-mode from"gh-r" id-as for \
extract"!" lsd-rs/lsd \
extract"!" zyedidia/micro \
extract"!" cp"autocomplete/bat.zsh -> _bat" @sharkdp/bat \
extract"!" pick"usr/bin/fastfetch" \
fastfetch-cli/fastfetch \
atclone"./zoxide init zsh > init.zsh" atpull"%atclone" src"init.zsh" \
ajeetdsouza/zoxide \
atclone"./fzf --zsh > init.zsh" atpull="%atclone" src"init.zsh" \
junegunn/fzf \
atclone"./fnm env --use-on-cd --shell zsh > init.zsh; ./fnm completions --shell zsh > _fnm" atpull"%atclone" src"init.zsh" Schniz/fnm
case "$(uname -s)" in
Darwin)
# echo 'Mac OS X'
plugins=("${mac_plugins[@]}" "${plugins[@]}")
;;
Linux)
# echo 'Linux'
;;
CYGWIN* | MINGW32* | MSYS* | MINGW*)
# echo 'MS Windows'
;;
*)
# echo 'Other OS'
;;
esac
for plugin in $plugins; do plug $plugin; done
# Clean startup prompt
[ ! -f ~/.hushlogin ] && touch ~/.hushlogin
unsetopt PROMPT_SP
# Load and initialise completion system
autoload -Uz compinit
compinit
# load local scripts
zinit is-snippet id-as for \
$ZDOTDIR/snippets/exports \
$ZDOTDIR/snippets/aliases \
$ZDOTDIR/snippets/options \
$ZDOTDIR/snippets/bin
-5
View File
@@ -1,5 +0,0 @@
#!/usr/bin/env zsh
[ -x "$(command -v bat)" ] && alias cat="bat"
[ -x "$(command -v codium)" ] && alias code="codium"
[ -x "$(command -v nvim)" ] && alias v="nvim"
-5
View File
@@ -1,5 +0,0 @@
#!/usr/bin/env zsh
command -v zoxide > /dev/null 2>&1 && eval "$(zoxide init zsh)"
command -v starship > /dev/null 2>&1 && eval "$(starship init zsh)"
command -v opam > /dev/null 2>&1 && eval $(opam env)
-18
View File
@@ -1,18 +0,0 @@
#!/usr/bin/env zsh
HISTFILE="$ZDOTDIR"/.zsh_history
HISTSIZE=1000000
SAVEHIST=1000000
export MANWIDTH=999
export EDITOR="micro"
export PAGE="bat"
export VISUAL="micro"
export SUDO_EDITOR="micro"
export STARSHIP_CONFIG="$XDG_CONFIG_HOME"/starship/starship.toml
export NODE_OPTIONS="--dns-result-order=ipv4first"
export PATH="/home/trivk/.local/share/fnm:$PATH"
+20
View File
@@ -0,0 +1,20 @@
#!/usr/bin/env zsh
# Modern alternatives to traditional commands
alias cat='bat'
alias ls='lsd -A'
alias la='lsd -lA'
alias tree='lsd --tree'
alias nano='micro'
alias fetch='fastfetch'
# Git shortcuts
alias g='git'
alias gs='git status -sb'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gl='git pull'
# Docker shortcuts
alias docker='podman'
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env zsh
# Add GNU tools to PATH without 'g' prefix
local gnu_tools=(
"coreutils"
"findutils"
"gnu-tar"
"gnu-sed"
"gawk"
"gnu-indent"
"grep"
)
for tool in $gnu_tools; do
local gnubin="/opt/homebrew/opt/$tool/libexec/gnubin"
if [ -d "$gnubin" ]; then
case ":$PATH:" in
*":$gnubin:"*) ;;
*) export PATH="$gnubin:$PATH" ;;
esac
fi
done
# Add other bins separately since they have a different path structure
local bin_paths=(
"$HOME/.local/bin"
"/opt/homebrew/opt/gnu-getopt/bin"
)
for bin_path in $bin_paths; do
if [ -d "$bin_path" ]; then
case ":$PATH:" in
*":$bin_path:"*) ;;
*) export PATH="$bin_path:$PATH" ;;
esac
fi
done
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env zsh
export MANWIDTH=999
export EDITOR="micro"
export PAGER="bat"
export VISUAL="micro"
export SUDO_EDITOR="micro"
export COMPANY_DIR="$HOME/Documents/work/company/"
export STARSHIP_CONFIG="$XDG_CONFIG_HOME"/starship/starship.toml
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env zsh
unsetopt BEEP
setopt AUTO_CD
setopt GLOB_DOTS
setopt NOMATCH
setopt MENU_COMPLETE
setopt EXTENDED_GLOB
setopt INTERACTIVE_COMMENTS
setopt APPEND_HISTORY
setopt PUSHD_IGNORE_DUPS
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
HISTFILE="${ZDOTDIR:-$HOME}/.zsh_history"
HISTSIZE=5000000
SAVEHIST=5000000
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'lsd -1 --color=always --icon=always $realpath'
+12
View File
@@ -0,0 +1,12 @@
#!/usr/bin/env zsh
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)"
[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
# not to use aliases: zi or zini
declare -A ZINIT
ZINIT[NO_ALIASES]=1
ZINIT[LIST_COMMAND]='lsd --tree'
source "${ZINIT_HOME}/zinit.zsh"