dev: automated commit - 2025-11-05 07:35:03

This commit is contained in:
Mariano Z. 2025-11-05 07:35:03 -03:00
parent 83437f5901
commit fe1c04b281
10 changed files with 167 additions and 110 deletions

View file

@ -1,12 +1,21 @@
source $ZDOTDIR/init.zsh source $ZDOTDIR/init.zsh
# Initialize completions immediately
autoload -Uz compinit autoload -Uz compinit
if [ "$(date +'%j')" != "$(stat -f '%Sm' -t '%j' ~/.zcompdump 2>/dev/null)" ]; then
compinit
else
compinit -C
fi
# Load completion registrations _compile_zcompdump() {
source $ZDOTDIR/completions/external.zsh (zcompile "${ZDOTDIR:-$HOME}/.zcompdump" 2>/dev/null &) > /dev/null 2>&1 &!
}
_refresh_compinit() {
(compinit -C >/dev/null 2>&1; zcompile "${ZDOTDIR:-$HOME}/.zcompdump" 2>/dev/null &) > /dev/null 2>&1 &!
}
if [[ -n ${ZDOTDIR:-$HOME}/.zcompdump(#qN.md+1) ]] || [[ ! -f ${ZDOTDIR:-$HOME}/.zcompdump ]]; then
compinit -C
zsh-defer _compile_zcompdump
else
compinit -Cu
if [[ -n ${ZDOTDIR:-$HOME}/.zcompdump(#qN.mh+12) ]]; then
zsh-defer _refresh_compinit
fi
fi

View file

@ -17,27 +17,28 @@ for completion_file in ~/.local/share/zsh/*-autocomplete.zsh(N); do
fi fi
done done
if command -v eza &> /dev/null; then # Use 'which' instead of 'command -v' for faster checks (as per optimization article)
if which eza >/dev/null 2>&1; then
compdef _ls eza compdef _ls eza
fi fi
if command -v kubefwd &> /dev/null; then if which kubefwd >/dev/null 2>&1; then
_lazy_load_completion kubefwd "kubefwd completion zsh" _lazy_load_completion kubefwd "kubefwd completion zsh"
fi fi
if command -v bombadil &> /dev/null; then if which bombadil >/dev/null 2>&1; then
_lazy_load_completion bombadil "bombadil generate-completions zsh" _lazy_load_completion bombadil "bombadil generate-completions zsh"
fi fi
if command -v rop &> /dev/null; then if which rop >/dev/null 2>&1; then
eval "$(rop completion zsh)" eval "$(rop completion zsh)"
fi fi
if command -v goq &> /dev/null; then if which goq >/dev/null 2>&1; then
eval "$(goq completion zsh)" eval "$(goq completion zsh)"
fi fi
if command -v drop &> /dev/null; then if which drop >/dev/null 2>&1; then
eval "$(drop completion zsh)" eval "$(drop completion zsh)"
fi fi

View file

@ -1,6 +1,12 @@
#!/bin/zsh #!/bin/zsh
function _package_manager { function _package_manager {
# Set up completion on first call
if [[ -z "$_package_manager_completion_setup" ]]; then
compdef _package_manager_completion _package_manager p 2>/dev/null
_package_manager_completion_setup=1
fi
local pkg_manager="" local pkg_manager=""
if [[ -f bun.lockb ]]; then if [[ -f bun.lockb ]]; then
@ -16,12 +22,12 @@ function _package_manager {
fi fi
if [[ -f package.json ]] && [[ $1 != "run" ]] && [[ $1 != "install" ]] && [[ $1 != "add" ]] && [[ $1 != "remove" ]] && [[ $1 != "i" ]] && [[ $1 != "rm" ]]; then if [[ -f package.json ]] && [[ $1 != "run" ]] && [[ $1 != "install" ]] && [[ $1 != "add" ]] && [[ $1 != "remove" ]] && [[ $1 != "i" ]] && [[ $1 != "rm" ]]; then
if command -v jq >/dev/null 2>&1 && jq -e ".scripts[\"$1\"] != null" package.json >/dev/null 2>&1; then if which jq >/dev/null 2>&1 && jq -e ".scripts[\"$1\"] != null" package.json >/dev/null 2>&1; then
set -- "run" "$@" set -- "run" "$@"
fi fi
fi fi
if command -v corepack >/dev/null 2>&1; then if which corepack >/dev/null 2>&1; then
corepack ${pkg_manager} "$@" corepack ${pkg_manager} "$@"
else else
command ${pkg_manager} "$@" command ${pkg_manager} "$@"
@ -74,6 +80,12 @@ function zshrc {
} }
function yay() { function yay() {
# Set up completion on first call
if [[ -z "$_yay_completion_setup" ]]; then
compdef _yay_completion yay 2>/dev/null
_yay_completion_setup=1
fi
case "$1" in case "$1" in
update|"-Syu") update|"-Syu")
echo "Updating NixOS system..." echo "Updating NixOS system..."
@ -193,5 +205,4 @@ _yay_completion() {
_describe 'yay commands' opts _describe 'yay commands' opts
} }
compdef _package_manager_completion _package_manager p # Completion functions are set up when functions are first called
compdef _yay_completion yay

View file

@ -1,6 +1,12 @@
#!/bin/zsh #!/bin/zsh
function dc() { function dc() {
# Set up completion on first call
if [[ -z "$_dc_completion_setup" ]]; then
compdef _dc_completion dc 2>/dev/null
_dc_completion_setup=1
fi
if [[ "$1" == "-h" || "$1" == "--help" ]]; then if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "Usage: dc [commit_message]" echo "Usage: dc [commit_message]"
echo "Quickly commit all changes and push to remote" echo "Quickly commit all changes and push to remote"
@ -100,6 +106,12 @@ function nu() {
} }
function zrepo() { function zrepo() {
# Set up completion on first call
if [[ -z "$_zrepo_completion_setup" ]]; then
compdef _zrepo_completion zrepo 2>/dev/null
_zrepo_completion_setup=1
fi
if [[ "$1" == "-h" || "$1" == "--help" ]]; then if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "Usage: zrepo <repo-name>" echo "Usage: zrepo <repo-name>"
echo "Create a new bare git repository on remote server" echo "Create a new bare git repository on remote server"
@ -165,5 +177,4 @@ _zrepo_completion() {
_describe 'repository names' repos _describe 'repository names' repos
} }
compdef _dc_completion dc # Completion functions are set up when functions are first called
compdef _zrepo_completion zrepo

View file

@ -1,6 +1,12 @@
#!/bin/zsh #!/bin/zsh
function kf { function kf {
# Set up completion on first call
if [[ -z "$_kf_completion_setup" ]]; then
compdef _kf_completion kf 2>/dev/null
_kf_completion_setup=1
fi
if [[ "$1" == "-h" || "$1" == "--help" ]]; then if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "Usage: kf <cluster> [service-name[:port]] [service-name[:port]] ..." echo "Usage: kf <cluster> [service-name[:port]] [service-name[:port]] ..."
echo "Example: kf oc-dev-internal-eks-cluster oc-activate-web" echo "Example: kf oc-dev-internal-eks-cluster oc-activate-web"
@ -122,5 +128,5 @@ _rmq_passwd_completion() {
fi fi
} }
compdef _kf_completion kf # Completion functions are set up when functions are first called
compdef _rmq_passwd_completion rmq-passwd # rmq-passwd completion will be set up if/when that function is defined elsewhere

View file

@ -1,7 +1,6 @@
PLUGIN_DIR="$HOME/.local/share/zsh/plugins" PLUGIN_DIR="$HOME/.local/share/zsh/plugins"
mkdir -p "$PLUGIN_DIR" mkdir -p "$PLUGIN_DIR"
# Install plugins (only if missing)
plugins=( plugins=(
"blimmer/zsh-aws-vault" "blimmer/zsh-aws-vault"
"romkatv/zsh-defer" "romkatv/zsh-defer"
@ -15,11 +14,9 @@ plugins=(
"zsh-users/zsh-syntax-highlighting" "zsh-users/zsh-syntax-highlighting"
) )
# Plugin management function
zap() { zap() {
echo "⚡ Updating plugins..." echo "⚡ Updating plugins..."
# Update plugins sequentially (clean output)
for plugin in "${plugins[@]}"; do for plugin in "${plugins[@]}"; do
plugin_name=${plugin##*/} plugin_name=${plugin##*/}
@ -57,41 +54,70 @@ zap() {
for plugin in "${plugins[@]}"; do for plugin in "${plugins[@]}"; do
plugin_name=${plugin##*/} plugin_name=${plugin##*/}
[ -d "$PLUGIN_DIR/$plugin_name" ] || git clone --quiet "https://github.com/$plugin" "$PLUGIN_DIR/$plugin_name" --depth=1 [[ -d "$PLUGIN_DIR/$plugin_name" ]] || git clone --quiet "https://github.com/$plugin" "$PLUGIN_DIR/$plugin_name" --depth=1
done done
# Source plugins
source "$PLUGIN_DIR/zsh-defer/zsh-defer.plugin.zsh" source "$PLUGIN_DIR/zsh-defer/zsh-defer.plugin.zsh"
# Defer heavy plugins for faster startup
source "$PLUGIN_DIR/zsh-aws-vault/zsh-aws-vault.plugin.zsh" source "$PLUGIN_DIR/zsh-aws-vault/zsh-aws-vault.plugin.zsh"
_batch_defer() {
local files=("$@")
for file in "${files[@]}"; do
[[ -f "$file" ]] && source "$file"
done
}
zsh-defer source "$PLUGIN_DIR/zsh-autosuggestions/zsh-autosuggestions.zsh" zsh-defer source "$PLUGIN_DIR/zsh-autosuggestions/zsh-autosuggestions.zsh"
zsh-defer source "$PLUGIN_DIR/zsh-autopair/autopair.zsh" zsh-defer source "$PLUGIN_DIR/zsh-autopair/autopair.zsh"
zsh-defer source "$PLUGIN_DIR/zsh-history-substring-search/zsh-history-substring-search.zsh" zsh-defer source "$PLUGIN_DIR/zsh-history-substring-search/zsh-history-substring-search.zsh"
zsh-defer source "$PLUGIN_DIR/fzf-tab/fzf-tab.plugin.zsh"
zsh-defer source "$PLUGIN_DIR/fzf/shell/completion.zsh"
zsh-defer source "$PLUGIN_DIR/fzf/shell/key-bindings.zsh"
zsh-defer source "$PLUGIN_DIR/vim/vim.plugin.zsh"
source "$PLUGIN_DIR/minimal/minimal.zsh" source "$PLUGIN_DIR/minimal/minimal.zsh"
# Source config files
source "$ZDOTDIR/opts.zsh" source "$ZDOTDIR/opts.zsh"
source "$ZDOTDIR/rose-pine.sh" source "$ZDOTDIR/rose-pine.sh"
#source "$ZDOTDIR/maintenance.zsh"
# Defer loading source "$ZDOTDIR/tmux.zsh"
zsh-defer source "$PLUGIN_DIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
# Load function files zsh-defer _batch_defer "$ZDOTDIR/alias.zsh" "$ZDOTDIR/keymap.zsh" "$ZDOTDIR/path.zsh" "$ZDOTDIR/pnpm.zsh" "$ZDOTDIR/mise.zsh"
for func_file in "$ZDOTDIR/functions"/*.zsh; do
zsh-defer source "$func_file"
done
# Load external completions local func_files=("$ZDOTDIR/functions"/*.zsh)
zsh-defer source "$ZDOTDIR/completions/external.zsh" zsh-defer _batch_defer "${func_files[@]}" "$ZDOTDIR/completions/external.zsh"
# Load other config files zsh-defer _batch_defer \
for config in tmux.zsh alias.zsh keymap.zsh path.zsh pnpm.zsh mise.zsh; do "$PLUGIN_DIR/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" \
zsh-defer source "$ZDOTDIR/$config" "$PLUGIN_DIR/fzf-tab/fzf-tab.plugin.zsh" \
done "$PLUGIN_DIR/fzf/shell/completion.zsh" \
"$PLUGIN_DIR/fzf/shell/key-bindings.zsh" \
"$PLUGIN_DIR/vim/vim.plugin.zsh"
_compile_zsh_files() {
(
local files=(
"$ZDOTDIR/init.zsh"
"$ZDOTDIR/opts.zsh"
"$ZDOTDIR/rose-pine.sh"
"$ZDOTDIR/completions/external.zsh"
"$ZDOTDIR/tmux.zsh"
"$ZDOTDIR/alias.zsh"
"$ZDOTDIR/keymap.zsh"
"$ZDOTDIR/path.zsh"
"$ZDOTDIR/pnpm.zsh"
"$ZDOTDIR/mise.zsh"
)
for func_file in "$ZDOTDIR/functions"/*.zsh; do
files+=("$func_file")
done
for file in "${files[@]}"; do
[[ ! -f "$file" ]] && continue
local zwc="${file}.zwc"
if [[ "$file" -nt "$zwc" ]] || [[ ! -f "$zwc" ]]; then
zcompile "$file" 2>/dev/null &
fi
done
wait
) > /dev/null 2>&1 &!
}
zsh-defer _compile_zsh_files

View file

@ -1,15 +1,25 @@
# Source it # Lazy load mise activation (only initialize when mise is actually called)
eval "$($HOME/.local/bin/mise activate zsh)" # This saves ~50-100ms on every shell startup
mise() {
# Install mise if not present (with caching to avoid repeated checks) # Initialize mise only once
if ! command -v mise &> /dev/null && [[ ! -f ~/.local/bin/mise ]]; then if ! which mise >/dev/null 2>&1; then
echo "Installing mise..." # Check if mise binary exists
mkdir -p ~/.local/bin if [[ -f ~/.local/bin/mise ]]; then
curl https://mise.jdx.dev/mise-latest-linux-x64 > ~/.local/bin/mise eval "$(~/.local/bin/mise activate zsh)"
chmod +x ~/.local/bin/mise else
~/.local/bin/mise install # Install mise if missing
fi echo "Installing mise..."
mkdir -p ~/.local/bin
curl -s https://mise.jdx.dev/mise-latest-linux-x64 > ~/.local/bin/mise
chmod +x ~/.local/bin/mise
~/.local/bin/mise install
eval "$(~/.local/bin/mise activate zsh)"
fi
# Set up completion after mise is initialized
compdef _mise mise 2>/dev/null
fi
command mise "$@"
}
#compdef mise #compdef mise
local curcontext="$curcontext" local curcontext="$curcontext"
@ -28,7 +38,7 @@ _mise() {
typeset -A opt_args typeset -A opt_args
local curcontext="$curcontext" spec cache_policy local curcontext="$curcontext" spec cache_policy
if ! command -v usage &> /dev/null; then if ! which usage >/dev/null 2>&1; then
echo >&2 echo >&2
echo "Error: usage CLI not found. This is required for completions to work in mise." >&2 echo "Error: usage CLI not found. This is required for completions to work in mise." >&2
echo "See https://usage.jdx.dev for more information." >&2 echo "See https://usage.jdx.dev for more information." >&2
@ -54,5 +64,6 @@ _mise() {
if [ "$funcstack[1]" = "_mise" ]; then if [ "$funcstack[1]" = "_mise" ]; then
_mise "$@" _mise "$@"
else else
compdef _mise mise # Skip completion setup when deferred - it will be set up when mise is first called
# This prevents blocking during shell startup
fi fi

View file

@ -1,38 +1,29 @@
function update_path() { # Optimized PATH setup - combine all additions into single operation
# Define directories to add to PATH # Build PATH array and export once (faster than multiple exports)
local dirs=( local new_path_dirs=(
"/usr/local/texlive/2024/bin/x86_64-linux" "/usr/local/texlive/2024/bin/x86_64-linux"
"$HOME/.local/bin" "$HOME/.local/bin"
"$HOME/.bin" "$HOME/.bin"
"$HOME/.dotnet/tools" "$HOME/.dotnet/tools"
"$HOME/.local/share/npm/bin" "$HOME/.local/share/npm/bin"
"$HOME/.local/share/cargo/bin" "$HOME/.local/share/cargo/bin"
"$HOME/.local/share/go/bin" "$HOME/.local/share/go/bin"
"$HOME/.local/share/flatpak/exports/share" "$HOME/.local/share/flatpak/exports/share"
"/var/lib/flatpak/exports/share" "$HOME/AppImages/"
) "/var/lib/flatpak/exports/share"
)
# Prepare new PATH variable # Build PATH only with directories that exist (single loop, single export)
local new_path="" local new_path=""
for dir in "${new_path_dirs[@]}"; do
[[ -d "$dir" ]] && new_path="${new_path:+$new_path:}$dir"
done
# Add directories if they exist # Export PATH once if we have additions
for dir in "${dirs[@]}"; do [[ -n "$new_path" ]] && export PATH="$new_path:$PATH"
if [ -d "$dir" ]; then
new_path="${new_path:+$new_path:}$dir"
fi
done
# Set PATH with current values if they don't already exist in the path # Set MANPATH and INFOPATH if texlive directory exists
if [[ -n "$new_path" ]]; then [[ -d "/usr/local/texlive/2024/texmf-dist/doc/man" ]] && {
export PATH="$new_path:$PATH" export MANPATH="/usr/local/texlive/2024/texmf-dist/doc/man:${MANPATH:-}"
fi export INFOPATH="/usr/local/texlive/2024/texmf-dist/doc/info:${INFOPATH:-}"
# Set MANPATH and INFOPATH if texlive directory exists
if [ -d "/usr/local/texlive/2024/texmf-dist/doc/man" ]; then
export MANPATH="/usr/local/texlive/2024/texmf-dist/doc/man:${MANPATH:-}"
export INFOPATH="/usr/local/texlive/2024/texmf-dist/doc/info:${INFOPATH:-}"
fi
} }
# Run the function
update_path

View file

@ -1,24 +1,15 @@
if [ -z "$TMUX" ]; then if [ -z "$TMUX" ]; then
# If we're in SSH
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
echo "Welcome via SSH..." echo "Welcome via SSH..."
# If we're in a TTY without X
elif [ -z "$DISPLAY" ]; then elif [ -z "$DISPLAY" ]; then
# Optional X start code commented out :
# echo "Start X? ..."
# startx
# Regular terminal with no tmux
else else
tmux_sessions=$(tmux ls 2>/dev/null) if command -v timeout >/dev/null 2>&1; then
tmux_status=$? if timeout 0.1 sh -c 'tmux ls >/dev/null 2>&1' 2>/dev/null; then
if [ $tmux_status -ne 0 ]; then tmux attach -t default 2>/dev/null || tmux new -s default
echo "Press any key to cancel tmux autostart..."
read -t 0.7 -n 1 -s -r
if [ $? -ne 0 ]; then
tmux new -s default
fi fi
else elif tmux ls >/dev/null 2>&1; then
tmux attach -t default || tmux new -s default tmux attach -t default 2>/dev/null || tmux new -s default
fi fi
fi fi
fi fi

Binary file not shown.