From 678cfb76bab640002b9401832fa307d24b9e0d72 Mon Sep 17 00:00:00 2001 From: Uyanide Date: Sun, 26 Jul 2026 21:36:03 +0200 Subject: [PATCH] update zsh config --- config/shell/.config/zsh/.gitignore | 1 + config/shell/.config/zsh/.zsh_plugins.txt | 23 ++++---- config/shell/.config/zsh/.zsh_plugins_pre.txt | 8 +++ config/shell/.config/zsh/conf.d/.gitignore | 5 +- .../shell/.config/zsh/conf.d/01-options.zsh | 20 ++++--- .../.config/zsh/conf.d/02-completions.zsh | 28 ---------- config/shell/.config/zsh/conf.d/02-fpath.zsh | 53 +++++++++++++++++++ .../shell/.config/zsh/conf.d/03-compinit.zsh | 26 +++++++++ .../shell/.config/zsh/conf.d/03-plugins.zsh | 20 ------- config/shell/.config/zsh/conf.d/10-done.zsh | 25 +++++++-- config/shell/.config/zsh/conf.d/10-env.zsh | 2 +- config/shell/.config/zsh/conf.d/10-oops.zsh | 50 ++++++++++------- config/shell/.config/zsh/conf.d/10-sshs.zsh | 2 +- config/shell/.config/zsh/conf.d/60-alias.zsh | 5 +- config/shell/.config/zsh/conf.d/60-fetch.zsh | 27 +++++++++- .../shell/.config/zsh/conf.d/95-plugins.zsh | 15 ++++++ config/shell/.zprofile | 17 +++--- config/shell/.zshenv | 1 - config/shell/.zshrc | 2 - 19 files changed, 223 insertions(+), 107 deletions(-) create mode 100644 config/shell/.config/zsh/.zsh_plugins_pre.txt delete mode 100644 config/shell/.config/zsh/conf.d/02-completions.zsh create mode 100644 config/shell/.config/zsh/conf.d/02-fpath.zsh create mode 100644 config/shell/.config/zsh/conf.d/03-compinit.zsh delete mode 100644 config/shell/.config/zsh/conf.d/03-plugins.zsh create mode 100644 config/shell/.config/zsh/conf.d/95-plugins.zsh diff --git a/config/shell/.config/zsh/.gitignore b/config/shell/.config/zsh/.gitignore index ae0c608..95e33d5 100644 --- a/config/shell/.config/zsh/.gitignore +++ b/config/shell/.config/zsh/.gitignore @@ -1,3 +1,4 @@ # antidote generated/cache files .zsh_plugins.zsh +.zsh_plugins_pre.zsh .antidote/ diff --git a/config/shell/.config/zsh/.zsh_plugins.txt b/config/shell/.config/zsh/.zsh_plugins.txt index 73a3af0..dd72b1a 100644 --- a/config/shell/.config/zsh/.zsh_plugins.txt +++ b/config/shell/.config/zsh/.zsh_plugins.txt @@ -1,17 +1,18 @@ -# Syntax highlighting -zsh-users/zsh-syntax-highlighting +# Loaded by conf.d/95-plugins.zsh, AFTER compinit and after every conf.d file +# that defines a ZLE widget. The order below is the load order and is required. +# +# Completions live in .zsh_plugins_pre.txt — they must reach $fpath before +# compinit, so they cannot be listed here. -# Catppuccin Mocha theme for syntax highlighting -# catppuccin/zsh-syntax-highlighting path:themes/catppuccin_latte-zsh-syntax-highlighting.zsh -catppuccin/zsh-syntax-highlighting path:themes/catppuccin_mocha-zsh-syntax-highlighting.zsh +# Fuzzy tab completion — after compinit, before anything that wraps widgets +Aloxaf/fzf-tab # Fish-like autosuggestions zsh-users/zsh-autosuggestions -# Additional completions -zsh-users/zsh-completions +# Syntax highlighting — must stay last, it wraps every widget defined so far +zsh-users/zsh-syntax-highlighting -# Long command done notification — handled by conf.d/10-done.zsh - -# Fuzzy tab completion -Aloxaf/fzf-tab +# Catppuccin Mocha theme, layered on top of zsh-syntax-highlighting +# catppuccin/zsh-syntax-highlighting path:themes/catppuccin_latte-zsh-syntax-highlighting.zsh +catppuccin/zsh-syntax-highlighting path:themes/catppuccin_mocha-zsh-syntax-highlighting.zsh diff --git a/config/shell/.config/zsh/.zsh_plugins_pre.txt b/config/shell/.config/zsh/.zsh_plugins_pre.txt new file mode 100644 index 0000000..c0e56e2 --- /dev/null +++ b/config/shell/.config/zsh/.zsh_plugins_pre.txt @@ -0,0 +1,8 @@ +# Loaded by conf.d/02-fpath.zsh, BEFORE compinit. +# kind:fpath only appends to $fpath — nothing here gets sourced. +# +# path:src is required: kind:fpath appends the repo root, but the _* files +# live in src/, so without it compinit finds nothing. + +# Additional completions +zsh-users/zsh-completions path:src kind:fpath diff --git a/config/shell/.config/zsh/conf.d/.gitignore b/config/shell/.config/zsh/conf.d/.gitignore index 4212465..e877127 100644 --- a/config/shell/.config/zsh/conf.d/.gitignore +++ b/config/shell/.config/zsh/conf.d/.gitignore @@ -1,8 +1,8 @@ * !.gitignore !01-options.zsh -!02-completions.zsh -!03-plugins.zsh +!02-fpath.zsh +!03-compinit.zsh !10-done.zsh !10-env.zsh !10-oops.zsh @@ -11,3 +11,4 @@ !60-alias.zsh !60-direnv.zsh !60-fetch.zsh +!95-plugins.zsh diff --git a/config/shell/.config/zsh/conf.d/01-options.zsh b/config/shell/.config/zsh/conf.d/01-options.zsh index 1943c11..c8ebccb 100644 --- a/config/shell/.config/zsh/conf.d/01-options.zsh +++ b/config/shell/.config/zsh/conf.d/01-options.zsh @@ -1,14 +1,17 @@ # History -HISTFILE="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/history" +histdir="${XDG_DATA_HOME:-$HOME/.local/share}/zsh" +HISTFILE="${histdir}/history" +[[ -d $histdir ]] || mkdir -p "$histdir" +unset histdir + HISTSIZE=100000 SAVEHIST=100000 -setopt APPEND_HISTORY SHARE_HISTORY EXTENDED_HISTORY -setopt HIST_IGNORE_DUPS HIST_SAVE_NO_DUPS HIST_FIND_NO_DUPS -setopt HIST_IGNORE_SPACE HIST_REDUCE_BLANKS INC_APPEND_HISTORY -setopt HIST_VERIFY -mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/zsh" +setopt SHARE_HISTORY EXTENDED_HISTORY +setopt HIST_IGNORE_DUPS HIST_SAVE_NO_DUPS HIST_FIND_NO_DUPS +setopt HIST_IGNORE_SPACE HIST_REDUCE_BLANKS +setopt HIST_VERIFY # Shell options @@ -27,6 +30,7 @@ bindkey '^Z' undo # C-z uy_prepend_sudo() { if [[ $BUFFER == sudo\ * ]]; then BUFFER="${BUFFER#sudo }" + (( CURSOR -= 5 )) else BUFFER="sudo $BUFFER" CURSOR+=5 @@ -38,11 +42,11 @@ bindkey '^[s' uy_prepend_sudo # Edit current command in editor autoload -Uz edit-command-line zle -N edit-command-line -bindkey '^X' edit-command-line +bindkey '^X^E' edit-command-line # Magic space # bindkey ' ' magic-space # This is already handled by tab # zmv -autoload zmv +autoload -Uz zmv diff --git a/config/shell/.config/zsh/conf.d/02-completions.zsh b/config/shell/.config/zsh/conf.d/02-completions.zsh deleted file mode 100644 index 6c8369b..0000000 --- a/config/shell/.config/zsh/conf.d/02-completions.zsh +++ /dev/null @@ -1,28 +0,0 @@ -if [ -d "$HOME/.zfunc" ]; then - fpath=($HOME/.zfunc $fpath) -fi - -if [ -d "$HOME/.zsh/completions" ]; then - fpath=($HOME/.zsh/completions $fpath) -fi - -# Cache compinit: only regenerate dump once daily -autoload -Uz compinit -if [[ -n ${ZDOTDIR:-$HOME}/.zcompdump(#qN.mh+24) ]]; then - compinit -else - compinit -C -fi - -zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' -zstyle ':completion:*' menu select -zstyle ':completion:*' squeeze-slashes true -zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" -zstyle ':completion:*:descriptions' format '%F{cyan}-- %d --%f' -zstyle ':completion:*:warnings' format '%F{red}-- no matches --%f' - -# Jujutsu - -if (( $+commands[jj] )); then - source <(jj util completion zsh) -fi diff --git a/config/shell/.config/zsh/conf.d/02-fpath.zsh b/config/shell/.config/zsh/conf.d/02-fpath.zsh new file mode 100644 index 0000000..aaf8cde --- /dev/null +++ b/config/shell/.config/zsh/conf.d/02-fpath.zsh @@ -0,0 +1,53 @@ +# $fpath must be complete BEFORE compinit runs (03-compinit.zsh) + +if [[ -d "$HOME/.zfunc" ]]; then + fpath=("$HOME/.zfunc" $fpath) +fi + +if [[ -d "$HOME/.zsh/completions" ]]; then + fpath=("$HOME/.zsh/completions" $fpath) +fi + +# Antidote: system package → user-local clone → auto-bootstrap. +# Sourced here because the first `antidote load` happens below. + +_uy_antidote_dir="${XDG_DATA_HOME:-$HOME/.local/share}/antidote" + +if [[ -f /usr/share/zsh-antidote/antidote.zsh ]]; then + source /usr/share/zsh-antidote/antidote.zsh +elif [[ -f "$_uy_antidote_dir/antidote.zsh" ]]; then + source "$_uy_antidote_dir/antidote.zsh" +elif (( $+commands[git] )); then + _uy_antidote_stamp="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/antidote-bootstrap-failed" + + if [[ -z $_uy_antidote_stamp(#qN.mh-1) ]]; then + if (( $+commands[timeout] )); then + # -k: SIGKILL follows if git ignores the SIGTERM + timeout -k 5 20 git clone -q --depth=1 https://github.com/mattmc3/antidote.git "$_uy_antidote_dir" + else + git clone -q --depth=1 https://github.com/mattmc3/antidote.git "$_uy_antidote_dir" + fi + + if [[ -f "$_uy_antidote_dir/antidote.zsh" ]]; then + command rm -f -- "$_uy_antidote_stamp" + source "$_uy_antidote_dir/antidote.zsh" + else + # Drop the partial clone: `git clone` refuses to write into a + # non-empty directory, so leaving it behind never recovers. + [[ -d "$_uy_antidote_dir" ]] && command rm -rf -- "$_uy_antidote_dir" + [[ -d "${_uy_antidote_stamp:h}" ]] || mkdir -p "${_uy_antidote_stamp:h}" + : >| "$_uy_antidote_stamp" + print -u2 "zsh: antidote bootstrap failed; plugins disabled, retrying in an hour" + fi + fi +fi + +# Pre-compinit bundles — kind:fpath entries only, nothing is sourced. +if (( $+functions[antidote] )); then + _uy_zsh_plugins_pre="${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.zsh_plugins_pre.txt" + if [[ -f "$_uy_zsh_plugins_pre" ]]; then + antidote load "$_uy_zsh_plugins_pre" + fi +fi + +unset _uy_antidote_dir _uy_antidote_stamp _uy_zsh_plugins_pre diff --git a/config/shell/.config/zsh/conf.d/03-compinit.zsh b/config/shell/.config/zsh/conf.d/03-compinit.zsh new file mode 100644 index 0000000..c432e93 --- /dev/null +++ b/config/shell/.config/zsh/conf.d/03-compinit.zsh @@ -0,0 +1,26 @@ +# compinit +# +# Sits between 02-fpath.zsh (which finishes $fpath) and +# 95-plugins.zsh (which loads fzf-tab, and fzf-tab requires compinit first). + +# Keep the dump next to the other zsh state (cf. $HISTFILE). +_uy_zcompdump="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/zcompdump" +[[ -d "${_uy_zcompdump:h}" ]] || mkdir -p "${_uy_zcompdump:h}" + +# Cache compinit: only regenerate dump once daily +autoload -Uz compinit +if [[ -n $_uy_zcompdump(#qN.mh+24) ]]; then + compinit -d "$_uy_zcompdump" +else + compinit -C -d "$_uy_zcompdump" +fi + +unset _uy_zcompdump + +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' +# fzf-tab needs zsh's own menu off so it can capture the unambiguous prefix +zstyle ':completion:*' menu no +zstyle ':completion:*' squeeze-slashes true +zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" +zstyle ':completion:*:descriptions' format '%F{cyan}-- %d --%f' +zstyle ':completion:*:warnings' format '%F{red}-- no matches --%f' diff --git a/config/shell/.config/zsh/conf.d/03-plugins.zsh b/config/shell/.config/zsh/conf.d/03-plugins.zsh deleted file mode 100644 index 2fcdc6c..0000000 --- a/config/shell/.config/zsh/conf.d/03-plugins.zsh +++ /dev/null @@ -1,20 +0,0 @@ -_uy_antidote_dir="${XDG_DATA_HOME:-$HOME/.local/share}/antidote" - -# Find antidote: system package → user-local clone → auto-bootstrap -if [[ -f /usr/share/zsh-antidote/antidote.zsh ]]; then - source /usr/share/zsh-antidote/antidote.zsh -elif [[ -f "$_uy_antidote_dir/antidote.zsh" ]]; then - source "$_uy_antidote_dir/antidote.zsh" -elif (( $+commands[git] )); then - git clone --depth=1 https://github.com/mattmc3/antidote.git "$_uy_antidote_dir" - source "$_uy_antidote_dir/antidote.zsh" -fi - -if (( $+functions[antidote] )); then - _uy_zsh_plugins="${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.zsh_plugins.txt" - if [[ -f "$_uy_zsh_plugins" ]]; then - antidote load "$_uy_zsh_plugins" - fi -fi - -unset _uy_antidote_dir _uy_zsh_plugins diff --git a/config/shell/.config/zsh/conf.d/10-done.zsh b/config/shell/.config/zsh/conf.d/10-done.zsh index 590ba8c..dfc260f 100644 --- a/config/shell/.config/zsh/conf.d/10-done.zsh +++ b/config/shell/.config/zsh/conf.d/10-done.zsh @@ -7,13 +7,31 @@ zmodload zsh/datetime : ${uy_done_min_cmd_duration:=10} -: ${uy_done_exclude:='^(nvim|helix|hx|vim|vi|nano|less|more|man|ssh|top|htop|btop)$'} +: ${uy_done_exclude:='^(nvim|helix|hx|vim|vi|nano|less|more|man|ssh|top|htop|btop|sudoedit)$'} uy_done_get_focused_window_id() { (( $+commands[jq] )) || return niri msg --json focused-window 2>/dev/null | jq -r '.id // empty' } +uy_done_cmd_name() { + local -a words + words=(${(z)1}) + + while (( $#words )); do + case $words[1] in + *=*) ;; + -*) ;; + sudo|doas|env|command|builtin|exec|nohup|nice|ionice|time|stdbuf|setsid) ;; + *) REPLY=${words[1]:t}; return ;; + esac + shift words + done + + # Nothing but wrappers — fall back to the first word. + REPLY=${1%% *} +} + uy_done_preexec() { uy_done_cmd="$1" uy_done_start=$EPOCHSECONDS @@ -30,8 +48,9 @@ uy_done_precmd() { (( elapsed >= uy_done_min_cmd_duration )) || return # skip excluded commands - local cmd_name="${uy_done_cmd%% *}" - [[ "$cmd_name" =~ $uy_done_exclude ]] && return + local REPLY + uy_done_cmd_name "$uy_done_cmd" + [[ "$REPLY" =~ $uy_done_exclude ]] && return # skip if window is still focused local current_id diff --git a/config/shell/.config/zsh/conf.d/10-env.zsh b/config/shell/.config/zsh/conf.d/10-env.zsh index 76d4622..4b4e27d 100644 --- a/config/shell/.config/zsh/conf.d/10-env.zsh +++ b/config/shell/.config/zsh/conf.d/10-env.zsh @@ -23,7 +23,7 @@ fi # GPG if (( $+commands[gpg] )); then - export GPG_TTY=$(tty) + export GPG_TTY=$TTY fi # Catppuccin Mocha — autosuggestions color diff --git a/config/shell/.config/zsh/conf.d/10-oops.zsh b/config/shell/.config/zsh/conf.d/10-oops.zsh index 4677018..e583199 100644 --- a/config/shell/.config/zsh/conf.d/10-oops.zsh +++ b/config/shell/.config/zsh/conf.d/10-oops.zsh @@ -1,5 +1,9 @@ # Remove the last command from history (both memory and file). -# The alias has a leading space so "oops" itself is not recorded (HIST_IGNORE_SPACE). +# +# NOTE: other shells running concurrently still hold the entry in their own +# in-memory history and can write it back; SHARE_HISTORY does not propagate +# deletions. + uy_oops_confirm() { # Flush current session to file so we operate on the latest state fc -W @@ -9,25 +13,28 @@ uy_oops_confirm() { return 1 fi - # Read the last entry (may span multiple lines if it ends with \) - local -a entry - local line - while IFS= read -r line; do - entry+=("$line") - # EXTENDED_HISTORY continuation lines end with a literal backslash - [[ "$line" == *'\' ]] || break - done < <(tail -n 50 "$HISTFILE" | tac) - # entry is reversed (last line first), flip it back + # Find where the last entry starts. An entry continues onto the next line + # when the current one ends in a backslash; zsh writes a command that itself + # ends in a backslash as "\ " (trailing space), so the marker is unambiguous. + # Walking forward and remembering the start of each entry is exact for + # entries of any length — scanning backwards over a fixed window is not. + local start + start=$(awk '{ if (!cont) start = NR; cont = /\\$/ } END { print start + 0 }' "$HISTFILE") + + if [[ -z "$start" ]] || (( start < 1 )); then + print -P "%F{yellow}Could not parse last history entry.%f" + return 1 + fi + local -a ordered - for (( i=${#entry[@]}; i>=1; i-- )); do - ordered+=("${entry[$i]}") - done + ordered=("${(@f)$(tail -n +"$start" "$HISTFILE")}") if (( ${#ordered[@]} == 0 )); then print -P "%F{yellow}Could not parse last history entry.%f" return 1 fi + local line print -P "About to permanently delete the last command from history:" for line in "${ordered[@]}"; do print -P " %F{red}${line}%f" @@ -38,17 +45,22 @@ uy_oops_confirm() { read -r reply if [[ -z "$reply" || "$reply" == [yY]* ]]; then - # Delete the last N lines (the full entry) from the file + # Keep everything before the entry. start-1 == 0 (the entry is the only + # one) correctly leaves an empty file. local n=${#ordered[@]} - head -n -"$n" "$HISTFILE" > "$HISTFILE.tmp" && mv "$HISTFILE.tmp" "$HISTFILE" - # Reload history from the updated file - fc -R + head -n $(( start - 1 )) "$HISTFILE" > "$HISTFILE.tmp" && mv "$HISTFILE.tmp" "$HISTFILE" + # Replace the in-memory history with the updated file. + # `fc -R` would *append* the file on top of what is already in memory, + # which both duplicates every entry and leaves the deleted command in + # memory — the next `fc -W` (e.g. the one at the top of this function + # on a second `oops`) would then write it straight back to the file. + fc -p "$HISTFILE" $HISTSIZE $SAVEHIST print -P "%F{green}Deleted ($n line(s) removed).%f" else - # Reload anyway to stay in sync - fc -R + # Nothing was modified, so there is nothing to reload. print -P "%F{yellow}Cancelled.%f" fi } +# The alias has a leading space so "oops" itself is not recorded (HIST_IGNORE_SPACE). alias oops=' uy_oops_confirm' diff --git a/config/shell/.config/zsh/conf.d/10-sshs.zsh b/config/shell/.config/zsh/conf.d/10-sshs.zsh index bf56012..61c1837 100644 --- a/config/shell/.config/zsh/conf.d/10-sshs.zsh +++ b/config/shell/.config/zsh/conf.d/10-sshs.zsh @@ -2,7 +2,7 @@ # $uy_ssh_keys should be set in a device-specific file or left empty for defaults if [[ "${UY_ENABLE_GPG_AGENT_SSH:-0}" = "1" ]] && - (( $+commands[gpg-init] )) && (( $+commands[gpgconf] )); then + [[ -x "$HOME/.local/scripts/gpg-init" ]] && (( $+commands[gpgconf] )); then : # GPG agent handles SSH — nothing to do elif [[ "${UY_USING_SSH_AGENT:-0}" = "1" ]]; then diff --git a/config/shell/.config/zsh/conf.d/60-alias.zsh b/config/shell/.config/zsh/conf.d/60-alias.zsh index 3ce52ab..861f5a2 100644 --- a/config/shell/.config/zsh/conf.d/60-alias.zsh +++ b/config/shell/.config/zsh/conf.d/60-alias.zsh @@ -121,7 +121,7 @@ copy() { # wget if (( $+commands[wget] )); then - alias wget="wget -c " + alias wget="wget -c" fi # pacman @@ -233,6 +233,7 @@ if (( $+commands[jj] )); then pos=${2:-@-} jj bookmark move "$branch" --to "$pos" jj git push + unfunction default_branch } alias jja="jj log -r 'all()' -T builtin_log_detailed" @@ -242,7 +243,7 @@ fi # wl-paste if (( $+commands[wl-paste] )); then - alias -g C="| wl-copy" + alias -g COPY="| wl-copy" fi # Redirects diff --git a/config/shell/.config/zsh/conf.d/60-fetch.zsh b/config/shell/.config/zsh/conf.d/60-fetch.zsh index a30e290..8979270 100644 --- a/config/shell/.config/zsh/conf.d/60-fetch.zsh +++ b/config/shell/.config/zsh/conf.d/60-fetch.zsh @@ -1,6 +1,6 @@ -# Detect logo capability +# Detect logo capability. -if [[ -z "$uy_fetch_logo_type" ]]; then +_uy_fetch_probe() { if (( $+commands[kgp-query] )) && kgp-query 2>/dev/null; then uy_fetch_logo_type=kitty elif (( $+commands[sixel-query] )) && sixel-query 2>/dev/null; then @@ -10,8 +10,31 @@ if [[ -z "$uy_fetch_logo_type" ]]; then else uy_fetch_logo_type=auto fi +} + +if [[ -z "$uy_fetch_logo_type" ]]; then + if [[ -t 0 ]] && (( $+commands[kgp-query] || $+commands[sixel-query] )); then + _uy_fetch_cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/logo-type" + # Terminal identity, sanitised down to a single path component + _uy_fetch_cache_file="$_uy_fetch_cache_dir/${${TERM:-none}//[^A-Za-z0-9._-]/_}@${${TERM_PROGRAM:-none}//[^A-Za-z0-9._-]/_}" + + [[ -s "$_uy_fetch_cache_file" ]] && uy_fetch_logo_type="$(<"$_uy_fetch_cache_file")" + + # Covers both a cache miss and a cache file holding anything unexpected + if [[ "$uy_fetch_logo_type" != (kitty|sixel|logo|symbols|auto) ]]; then + _uy_fetch_probe + [[ -d "$_uy_fetch_cache_dir" ]] || mkdir -p "$_uy_fetch_cache_dir" + print -r -- "$uy_fetch_logo_type" >| "$_uy_fetch_cache_file" + fi + + unset _uy_fetch_cache_dir _uy_fetch_cache_file + else + _uy_fetch_probe + fi fi +unfunction _uy_fetch_probe + : ${uy_fetch_color:="38;2;137;180;250"} # Build fastfetch args (arrays to handle paths with spaces safely) diff --git a/config/shell/.config/zsh/conf.d/95-plugins.zsh b/config/shell/.config/zsh/conf.d/95-plugins.zsh new file mode 100644 index 0000000..66e93e3 --- /dev/null +++ b/config/shell/.config/zsh/conf.d/95-plugins.zsh @@ -0,0 +1,15 @@ +# Plugins that wrap ZLE widgets. Deliberately the last conf.d file: +# - fzf-tab must load after compinit (03-compinit.zsh) +# - fzf-tab must load before the plugins that wrap widgets +# - zsh-syntax-highlighting must load after everything that defines a widget, +# i.e. after 50-prompt.zsh (zle hooks) and 60-alias.zsh (`fzf --zsh`) +# Load order inside .zsh_plugins.txt matters and encodes the same rules. + +if (( $+functions[antidote] )); then + _uy_zsh_plugins="${XDG_CONFIG_HOME:-$HOME/.config}/zsh/.zsh_plugins.txt" + if [[ -f "$_uy_zsh_plugins" ]]; then + antidote load "$_uy_zsh_plugins" + fi +fi + +unset _uy_zsh_plugins diff --git a/config/shell/.zprofile b/config/shell/.zprofile index 36ef79f..ab58c74 100644 --- a/config/shell/.zprofile +++ b/config/shell/.zprofile @@ -12,11 +12,14 @@ fi # SSH agent -if (( $+commands[ssh-add] )) && (( $+commands[ssh-agent] )) && - { [[ -z "$SSH_AUTH_SOCK" ]] || - { ssh-add -l &>/dev/null; [[ $? -eq 2 ]]; } } && - [[ -x "$HOME/.local/scripts/ssh-init" ]]; then - unset SSH_AUTH_SOCK - eval "$($HOME/.local/scripts/ssh-init 2>/dev/null)" &>/dev/null - export UY_USING_SSH_AGENT=1 +if (( $+commands[ssh-add] )) && (( $+commands[ssh-agent] )); then + # ssh-add -l: 0 = agent with keys, 1 = agent without keys, 2 = no agent + if [[ -n "$SSH_AUTH_SOCK" ]] && + { ssh-add -l &>/dev/null; [[ $? -ne 2 ]]; }; then + export UY_USING_SSH_AGENT=1 + elif [[ -x "$HOME/.local/scripts/ssh-init" ]]; then + unset SSH_AUTH_SOCK + eval "$($HOME/.local/scripts/ssh-init 2>/dev/null)" &>/dev/null + [[ -n "$SSH_AUTH_SOCK" ]] && export UY_USING_SSH_AGENT=1 + fi fi diff --git a/config/shell/.zshenv b/config/shell/.zshenv index f90f882..fd209a3 100644 --- a/config/shell/.zshenv +++ b/config/shell/.zshenv @@ -45,7 +45,6 @@ fi # Paths [[ -f "$HOME/.cargo/env" ]] && source "$HOME/.cargo/env" -(( $+commands[opam] )) && eval "$(opam env)" prepend_path "$HOME/.local/share/fnm/aliases/default/bin" # 'fnm env' is eval'ed in .zshrc prepend_path "$HOME/.cargo/bin" prepend_path "$HOME/go/bin" diff --git a/config/shell/.zshrc b/config/shell/.zshrc index 6a7c8e8..3ab852c 100644 --- a/config/shell/.zshrc +++ b/config/shell/.zshrc @@ -1,7 +1,5 @@ #!/hint/zsh -[[ $- != *i* ]] && return - for _f in "${XDG_CONFIG_HOME:-$HOME/.config}"/zsh/conf.d/*.zsh(N); do source "$_f" done