Use XDG base dir vars instead of defaults

This commit is contained in:
Kenneth Benzie (Benie)
2024-09-10 07:31:17 -07:00
parent 1e53581d17
commit 8812ef8544
5 changed files with 61 additions and 34 deletions

21
zshrc
View File

@@ -3,8 +3,8 @@
# Load plugin scripts
source-plugin() {
local shared_plugin=~/.local/share/zsh/plugins/$1/$1.plugin.zsh
local local_plugin=~/.config/zsh/$1/$1.plugin.zsh
local shared_plugin=${XDG_DATA_HOME:-$HOME/.local/share}/zsh/plugins/$1/$1.plugin.zsh
local local_plugin=${XDG_CONFIG_HOME:-$HOME/.config}/zsh/$1/$1.plugin.zsh
if [ -f $shared_plugin ]; then
source $shared_plugin
elif [ -f $local_plugin ]; then
@@ -76,7 +76,7 @@ setopt completeinword
# Initialize completions
autoload -U compinit
compinit -d ~/.cache/zsh/compdump
compinit -d ${XDG_CACHE_HOME:-$HOME/.cache}/zsh/compdump
# Add pip to the old completion engine if present
if command -v pip &> /dev/null; then
@@ -192,14 +192,19 @@ frequent-directory Documents "$HOME/Documents"
frequent-directory Downloads "$HOME/Downloads"
frequent-directory Projects "$HOME/Projects"
frequent-directory Sandbox "$HOME/Sandbox"
frequent-directory cache "$HOME/.cache"
frequent-directory config "$HOME/.config"
frequent-directory cache "${XDG_CACHE_HOME:-$HOME/.cache}"
frequent-directory config "${XDG_CONFIG_HOME:-$HOME/.config}"
frequent-directory local "$HOME/.local"
# Load work related config
[ -f ~/.config/work/zshrc ] && source ~/.config/work/zshrc
[ -f ~/.config/private/zshrc ] && source ~/.config/private/zshrc
[ -f ~/.config/zsh/local ] && source ~/.config/zsh/local
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/work/zshrc ] && \
source ${XDG_CONFIG_HOME:-$HOME/.config}/work/zshrc
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/private/zshrc ] && \
source ${XDG_CONFIG_HOME:-$HOME/.config}/private/zshrc
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/local ] && \
source ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/local
[ -f ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/zshrc.local ] && \
source ${XDG_CONFIG_HOME:-$HOME/.config}/zsh/zshrc.local
# Aliases
alias grep='grep --color=always'