Begin moving to new XDG compliant directory structure

This commit is contained in:
Marty Oehme 2019-02-24 11:06:50 +01:00
parent 50c1b6cacb
commit 5e50aafcd0
23 changed files with 27 additions and 8 deletions

4
.zshenv Normal file
View file

@ -0,0 +1,4 @@
export XDG_CONFIG_DIR="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"

31
.zshrc
View file

@ -1,9 +1,23 @@
#!/bin/zsh
## DEBUG INFORMATION
### DEFAULT DIRECTORY STRUCTURE
#
# ~/
# - .zshrc > Initial setup, should not need to be changed
# - .bashrc > Bash setup (empty for my dotfiles)
# - .Xresources > Initial Xresources setup, redirects to .config/.Xresources.d/
# - .tmux > Tmux setup (would love to put this into .config/ )
# - .config/ > all other (program) configuration should go in this dir
# --------- .zshrc.d/ > The actual zsh setup files, see their configuration below
# --------- .Xresources.d/ > The actual Xresources setup files
# --------- .zgen/ > The zsh plugin manager
# - .dotfiles/ > the version control of dotfiles
#
####
## Show debug information
#
# ZSH_SETUP_SHOW_DEBUG="true"
#
# Uncomment the above line to get debug information during the script setup.
print_dbg() {
if [ -z $ZSH_SETUP_SHOW_DEBUG ]; then
@ -15,17 +29,18 @@ print_dbg() {
# Clone zgen if you haven't already
check_zgen_installation() {
if [[ -z "$ZGEN_PARENT_DIR" ]]; then
ZGEN_PARENT_DIR=$HOME
ZGEN_PARENT_DIR=${${XDG_CONFIG_DIR}:="$HOME/.config/"}
ZGEN_DIR="$ZGEN_PARENT_DIR/zgen"
fi
if [[ ! -f $ZGEN_PARENT_DIR/.zgen/zgen.zsh ]]; then
if [[ ! -f $ZGEN_DIR/zgen.zsh ]]; then
if [[ ! -d "$ZGEN_PARENT_DIR" ]]; then
mkdir -p "$ZGEN_PARENT_DIR"
fi
pushd $ZGEN_PARENT_DIR
git clone https://github.com/tarjoilija/zgen.git ./.zgen
git clone https://github.com/tarjoilija/zgen.git $ZGEN_DIR
popd
fi
source $ZGEN_PARENT_DIR/.zgen/zgen.zsh
source $ZGEN_DIR/zgen.zsh
unset ZGEN_PARENT_DIR
}
@ -65,9 +80,9 @@ check_zgen_installation() {
# Set ZSH_CONFIG_DIR to default to ~/.zsh.d, or let user override
# Exit early if no configuration directory has been found
if [ ! -d ${ZSH_CONFIG_DIR:="$HOME/.zsh.d"} ]; then
if [ ! -d ${ZSH_CONFIG_DIR:="${XDG_CONFIG_DIR:-$HOME/.config}/zsh"} ]; then
# If the user explicitly overrode the path give him an error
if [ ! $ZSH_CONFIG_DIR = "$HOME/.zsh.d" ]; then
if [ ! $ZSH_CONFIG_DIR = "${XDG_CONFIG_DIR:-$HOME/.config/}/zsh" ]; then
printf "\$ZSH_CONFIG_DIR=$ZSH_CONFIG_DIR/ does not exist.\n"
fi
PS1="$HOME $ "