From a508364ae96dd2196c33867832d960c70f7c681c Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sun, 31 Jul 2022 14:45:26 -0500 Subject: [PATCH] feat: use xdg spec --- .config/zsh/config/init.zsh | 18 ++++++++++++++++++ .config/zsh/config/omz/init.zsh | 2 +- .config/zsh/config/profile/profile/env.zsh | 14 +++++++------- .config/zsh/config/style/init.zsh | 2 +- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.config/zsh/config/init.zsh b/.config/zsh/config/init.zsh index 8beca57..d311bd4 100644 --- a/.config/zsh/config/init.zsh +++ b/.config/zsh/config/init.zsh @@ -4,7 +4,25 @@ configure() { autoload -U +X bashcompinit && bashcompinit } +set-xdg-vars() { + # Based on https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html + # and https://wiki.archlinux.org/title/XDG_Base_Directory + + export XDG_CONFIG_HOME="${HOME}/.config" + export XDG_CACHE_HOME="${HOME}/.cache" + export XDG_DATA_HOME="${HOME}/.local/share" + export XDG_STATE_HOME="${HOME}/.local/state" + export XDG_DATA_DIRS="/usr/local/share:/usr/share" + export XDG_CONFIG_DIRS="/etc/xdg" + + # XDG_RUNTIME_DIR + # Not set because this is generally resolved by the underlying system, + # AKA shit can break bad if this is set wrong +} + init() { + set-xdg-vars + local wkdir="${BASE_ZSH_CONFIG_DIR}/config" source "${wkdir}/themes/init.zsh" source "${wkdir}/profile/init.zsh" diff --git a/.config/zsh/config/omz/init.zsh b/.config/zsh/config/omz/init.zsh index 79e525b..cdbbfc0 100644 --- a/.config/zsh/config/omz/init.zsh +++ b/.config/zsh/config/omz/init.zsh @@ -36,7 +36,7 @@ configure() { init() { local wkdir="${BASE_ZSH_CONFIG_DIR}/config/omz" - export ZSH="${HOME}/.local/share/omz" + export ZSH="${XDG_DATA_HOME}/omz" export ZSH_CUSTOM="${wkdir}/" } diff --git a/.config/zsh/config/profile/profile/env.zsh b/.config/zsh/config/profile/profile/env.zsh index 8fbe981..467e5b7 100644 --- a/.config/zsh/config/profile/profile/env.zsh +++ b/.config/zsh/config/profile/profile/env.zsh @@ -1,6 +1,6 @@ #!/usr/bin/env zsh -export PATH="${PATH}:${HOME}/.local/bin" +export PATH="${PATH}:${XDG_BIN_HOME}" ### Shell ### export LANG=en_US.UTF-8 @@ -9,19 +9,19 @@ export ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=2 export ZSH_AUTOSUGGEST_STRATEGY=(history completion) ### Autojump ### -source "${HOME}/.local/share/autojump/etc/profile.d/autojump.sh" -export PATH="${PATH}:${HOME}/.local/share/autojump/bin" +source "${XDG_DATA_HOME}/autojump/etc/profile.d/autojump.sh" +export PATH="${PATH}:${XDG_DATA_HOME}/autojump/bin" ### FZF ### function zvm_after_init() { - [[ -r "${HOME}/.config/fzf/fzf.zsh" ]] && source "${HOME}/.config/fzf/fzf.zsh" + [[ -r "${XDG_CONFIG_HOME}/fzf/fzf.zsh" ]] && source "${XDG_CONFIG_HOME}/fzf/fzf.zsh" } export FZF_DEFAULT_COMMAND='fd --hidden --exclude .git --color=always' export FZF_DEFAULT_OPTS="--height=80% --layout=reverse --info=inline --border --margin=1 --ansi" export FZF_CTRL_T_COMMAND="${FZF_DEFAULT_COMMAND}" ### Python ### -export PYENV_ROOT="${HOME}/.local/share/pyenv" +export PYENV_ROOT="${XDG_DATA_HOME}/pyenv" export PATH="${PATH}:${PYENV_ROOT}/bin" eval "$(pyenv init -)" @@ -84,9 +84,9 @@ else fi ### Rust ### -export CARGO_HOME="${HOME}/.local/share/cargo" +export CARGO_HOME="${XDG_DATA_HOME}/cargo" source "${CARGO_HOME}/env" -export RUSTUP_HOME="${HOME}/.local/share/rustup" +export RUSTUP_HOME="${XDG_DATA_HOME}/rustup" export PATH="${PATH}:${CARGO_HOME}/bin" ### Terminal Specific ### diff --git a/.config/zsh/config/style/init.zsh b/.config/zsh/config/style/init.zsh index 7ab79d3..4556862 100644 --- a/.config/zsh/config/style/init.zsh +++ b/.config/zsh/config/style/init.zsh @@ -1,7 +1,7 @@ configure() { # Enable Caching zstyle ':completion:*' use-cache on - zstyle ':completion:*' cache-path "${HOME}/.cache/.zcompcache" + zstyle ':completion:*' cache-path "${XDG_CACHE_HOME}/.zcompcache" ### Fzf Tab Configuration ### zstyle ':fzf-tab:*' fzf-pad 100