From ba37fa63e8cdedbe958ab51a6aaddcfa4ed2f65d Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Thu, 30 Jan 2014 00:19:00 +0100 Subject: [PATCH] zsh: use XDG_{CONFIG,CACHE}_HOME --- Makefile | 4 ++-- profile | 4 ++++ zprofile | 1 + zsh/.gitignore | 1 - zsh/lib/completion.zsh | 3 ++- zshrc | 9 ++++++--- 6 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 profile create mode 100644 zprofile diff --git a/Makefile b/Makefile index c9c01e4..033358f 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ APATH := $(realpath .) FILES := bin -DOTFILES := aliases bash* conky* flexget git* goobookrc msmtp* mutt ncmpcpp offlineimap* vim* weechat xbindkeysrc Xresources xprofile zsh* -CONFIGFILES := compton.conf mimeo.conf mpd retroarch xkb +DOTFILES := aliases bash* conky* flexget git* goobookrc msmtp* mutt ncmpcpp offlineimap* profile vim* weechat xbindkeysrc Xresources xprofile zprofile zshrc +CONFIGFILES := compton.conf mimeo.conf mpd retroarch xkb zsh .PHONY: install $(FILES) $(DOTFILES) $(CONFIGFILES) install: $(FILES) $(DOTFILES) $(CONFIGFILES) diff --git a/profile b/profile new file mode 100644 index 0000000..fc234d9 --- /dev/null +++ b/profile @@ -0,0 +1,4 @@ +export PATH="$HOME/bin:$PATH" +export XDG_CONFIG_HOME="$HOME/.config" +export XDG_DATA_HOME="$HOME/.local/share" +export XDG_CACHE_HOME="$HOME/.cache" diff --git a/zprofile b/zprofile new file mode 100644 index 0000000..53ca887 --- /dev/null +++ b/zprofile @@ -0,0 +1 @@ +emulate sh -c 'source ~/.profile' diff --git a/zsh/.gitignore b/zsh/.gitignore index 51a5ee6..536c39d 100644 --- a/zsh/.gitignore +++ b/zsh/.gitignore @@ -6,4 +6,3 @@ custom/* !custom/example.zsh *.swp !custom/example.zshcache -cache/ diff --git a/zsh/lib/completion.zsh b/zsh/lib/completion.zsh index d81b6eb..13d98cd 100644 --- a/zsh/lib/completion.zsh +++ b/zsh/lib/completion.zsh @@ -41,8 +41,9 @@ hosts=( zstyle ':completion:*:hosts' hosts $hosts # Use caching so that commands like apt and dpkg complete are useable +[[ -d "$XDG_CACHE_HOME/zsh" ]] || mkdir -p "$XDG_CACHE_HOME/zsh" zstyle ':completion::complete:*' use-cache 1 -zstyle ':completion::complete:*' cache-path $ZSH/cache/ +zstyle ':completion::complete:*' cache-path $XDG_CACHE_HOME/zsh # Don't complete uninteresting users zstyle ':completion:*:*:*:users' ignored-patterns \ diff --git a/zshrc b/zshrc index 653f974..7ad8443 100644 --- a/zshrc +++ b/zshrc @@ -1,5 +1,6 @@ -# Path to your oh-my-zsh configuration. -ZSH=$HOME/.zsh +# Path to config files +ZSH=$XDG_CONFIG_HOME/zsh +[[ ! -d "$ZSH" ]] && echo "Missing config dir: '$ZSH'" && return # Load all of the config files in $ZSH/lib that end in .zsh for config_file ($ZSH/lib/*.zsh); do @@ -16,7 +17,9 @@ typeset -U fpath # make fpath a unique array [[ -d ~/.zsh/functions ]] && fpath=(~/.zsh/functions $fpath) autoload -U ${fpath[1]}/*(:t) # loads all functions in the first element of fpath -autoload -U compinit; compinit +# initialise completion +[[ -d "$XDG_CACHE_HOME/zsh" ]] || mkdir -p "$XDG_CACHE_HOME/zsh" +autoload -U compinit; compinit -d "$XDG_CACHE_HOME/zsh/zcompdump" # miscelaneous options setopt extendedglob -- 2.48.1