From 3321d21f8b29d37fa1856d5cfb430039fa57e916 Mon Sep 17 00:00:00 2001 From: Konstantin Demin Date: Thu, 29 Feb 2024 01:04:53 +0300 Subject: [PATCH] zsh: rework ZDOTDIR redirection --- .cache/zsh/dots/.keep | 0 .config/dotfiles/gitignore | 2 +- .config/zsh.dots/.zshenv | 6 ++++++ .config/zsh/_.zsh | 2 +- .config/zsh/lib/selfservice.zsh | 1 + .zshenv | 1 - 6 files changed, 9 insertions(+), 3 deletions(-) delete mode 100644 .cache/zsh/dots/.keep create mode 100644 .config/zsh.dots/.zshenv diff --git a/.cache/zsh/dots/.keep b/.cache/zsh/dots/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/.config/dotfiles/gitignore b/.config/dotfiles/gitignore index 227dc03..ecce00b 100644 --- a/.config/dotfiles/gitignore +++ b/.config/dotfiles/gitignore @@ -2,7 +2,6 @@ !/.cache/zsh/compcache/.keep !/.cache/zsh/completion/.keep !/.cache/zsh/compzwc/.keep -!/.cache/zsh/dots/.keep !/.config/dotfiles/bin/.keep !/.config/dotfiles/gen-gitignore.sh !/.config/dotfiles/gitattributes @@ -12,6 +11,7 @@ !/.config/dotfiles/woodpecker.yml !/.config/htop/htoprc.dist !/.config/mc/ini.dist +!/.config/zsh.dots/.zshenv !/.config/zsh/_.zsh !/.config/zsh/_wip/enclave.zsh.wip !/.config/zsh/_wip/starship.zsh.sample diff --git a/.config/zsh.dots/.zshenv b/.config/zsh.dots/.zshenv new file mode 100644 index 0000000..235f892 --- /dev/null +++ b/.config/zsh.dots/.zshenv @@ -0,0 +1,6 @@ +#!/bin/zsh +if [[ -o interactive ]] ; then + ## early redirect + ZDOTDIR="${ZDOTDIR%/${ZDOTDIR:t2}}" + source "${ZDOTDIR}/.zshenv" +fi diff --git a/.config/zsh/_.zsh b/.config/zsh/_.zsh index 8f031da..fd1cfd2 100644 --- a/.config/zsh/_.zsh +++ b/.config/zsh/_.zsh @@ -18,7 +18,7 @@ unsetopt global_rcs ## safety measure: ## redirect all following activity within ZDOTDIR to cache -export ZDOTDIR="${ZSHU[d_cache]}/dots" +export ZDOTDIR="${ZDOTDIR}/.config/zsh.dots" ## cleanup: start from scratch for i ( a s f d ) ; do unhash -$i -m '*' ; done ; unset i diff --git a/.config/zsh/lib/selfservice.zsh b/.config/zsh/lib/selfservice.zsh index 3f8b263..fa7bf6b 100644 --- a/.config/zsh/lib/selfservice.zsh +++ b/.config/zsh/lib/selfservice.zsh @@ -63,6 +63,7 @@ z-reload() { ## reload or new session are required to regenerate compcache z-cache-flush() { find "${ZSHU[d_cache]}/" -xdev -type f '!' -name '.keep' -delete + find "${ZSHU[d_zdot]}/.config/zsh.dots/" -xdev -type f '!' -name '.zshenv' -delete z-zwc-flush z-zwc-gen } diff --git a/.zshenv b/.zshenv index ae8221c..5dbbacc 100644 --- a/.zshenv +++ b/.zshenv @@ -2,6 +2,5 @@ if [[ -o interactive ]] ; then ## early redirect : "${ZDOTDIR:=${HOME}}" - [ "${ZDOTDIR}" = "${HOME}/.cache/zsh/dots" ] && ZDOTDIR="${HOME}" source "${ZDOTDIR}/.config/zsh/_.zsh" fi