Skip to content

Commit

Permalink
Move common parts to zsh.common and fix make
Browse files Browse the repository at this point in the history
  • Loading branch information
abravalheri committed Jul 7, 2019
1 parent d592656 commit d7629b9
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 59 deletions.
7 changes: 7 additions & 0 deletions %dircolors/.config/zshrc.d/fix-dircolors.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env zsh
# Fix terminal colors
local __dircolors_config=~/.config/dircolors/dircolors.solarized-256-dark
if [ -f "${__dircolors_config}" ]; then
eval "$(dircolors "${__dircolors_config}")"
fi
unset __dircolors_config
39 changes: 2 additions & 37 deletions %zsh.grml/.zshrc.local
Original file line number Diff line number Diff line change
@@ -1,45 +1,10 @@
#!/usr/bin/env zsh
# Fix terminal colors
local __dircolors_config=~/.config/dircolors/dircolors.solarized-256-dark
if [ -f "${__dircolors_config}" ]; then
eval "$(dircolors "${__dircolors_config}")"
fi
unset __dircolors_config

# Adjust PATH
export -U PATH="$HOME/.local/bin:$PATH"
export -U FPATH="$XDG_CONFIG_HOME/zshrc.d/autoloaded/:$FPATH"

# Imports
# Source configurations from extra files {{{
function __zshrc_load_extra() {
local cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/zsh"
local fp="$cache_dir/extras-cache.zsh"
local -U extra priv list

if [ ! -f "$fp" ]; then
echo "Compiling extra zshrc files"
extra=(
# Meant for external installations, just check if file exists:
/usr/share/autojump/autojump.zs[h](N) # [h] -> POG to activate glob

# Check if the file is executable (so we can deactivate it with chmod)
$HOME/.config/zsh/+local*.zsh(xN)
# ^ Files specific to host, not shared via dotfiles
$HOME/.config/zshrc.d/?*.zsh(xN)
# ^ Files from other program configurations (e.g. TMUX)
)
set -x
mkdir -p "$cache_dir"
cat $extra > "$fp"
zcompile "$fp"
set +x
fi
source "$fp"
}
__zshrc_load_extra
unset -f __zshrc_load_extra # avoid lambdas so zprof can be used
# }}}
source "$XDG_CONFIG_HOME/zsh/autoload.zsh"
source "$XDG_CONFIG_HOME/zsh/extras.zsh"

# SSH/GPG Agents
ssh-init
Expand Down
21 changes: 10 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Define Targets
DOTFILES := ${HOME}/.dotfiles
XDG_CONFIG_HOME := ${HOME}/.config
ifneq (,$(wildcard "${XDG_CONFIG_HOME}/zsh"))
ifneq (,$(wildcard ${XDG_CONFIG_HOME}/zsh))
ZSH_USES_XDG = "true"
ZDOTDIR := ${XDG_CONFIG_HOME}/zsh
else
Expand All @@ -14,22 +14,21 @@ ZDOT_FLAGS := -maxdepth 1 \( -not -type d \) -and \( -iname ".pathrc" -or -iname

AUTOLOAD_FILES := $(shell find -L ${AUTOLOAD} -not -iname ".*" -not -iname "*.zwc" -not -type d)
ZDOT_FILES := $(shell find -L ${ZDOTDIR} -maxdepth 1 \( -not -type d \) -and \( -iname ".pathrc" -or -iname ".zsh*" \) -not -iname ".zsh_history" -not -iname ".*.zwc")
ZSH_FILES := $(shell find -L ${ZSHRCD} -maxdepth 1 -iname "*.zsh" -not -type d) \
$(shell find -L ${ZDOTDIR} -maxdepth 1 -iname "*.zsh" -not -type d)

AUTOLOAD_TARGET := $(addsuffix .zwc,${AUTOLOAD_FILES})
ZDOT_TARGET := $(addsuffix .zwc,${ZDOT_FILES})
ZSH_TARGET := ${ZSH_FILES:.zsh=.zwc}
TARGET := ${AUTOLOAD_TARGET} ${ZDOT_TARGET} ${ZSH_TARGET}
ZSH_FILES := $(shell find -L ${ZSHRCD} ${ZDOTDIR} -maxdepth 1 -iname "*.zsh" -not -type d)
SRC_FILES:= ${AUTOLOAD_FILES} ${ZDOT_FILES} ${ZSH_FILES}
TARGET := $(addsuffix .zwc,${SRC_FILES})

default: pre-compile

pre-compile: ${TARGET}

${ZDOT_TARGET} ${AUTOLOAD_TARGET}: %.zwc: %
zsh -c 'zcompile $<'
info:
@echo "ZDOTDIR ${ZDOTDIR}"
@echo "ZDOT: ${ZDOT_FILES}"
@echo "ZSH: ${ZSH_FILES}"
@echo "AUTOLOAD: ${AUTOLOAD_FILES}"

${ZSH_TARGET}: %.zwc: %.zsh
${TARGET}: %.zwc: %
zsh -c 'zcompile $<'

clean:
Expand Down
2 changes: 1 addition & 1 deletion brew/.config/zshrc.d/brew.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ __zshrc_brew() {
set -x
mkdir -p "$cache_dir"
"$brew_root/bin/brew" shellenv > "$fp"
zcompile "$fp"
zcompile "$fp" &!
set +x
break
fi
Expand Down
19 changes: 19 additions & 0 deletions zsh.common/.config/zsh/autoload.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env zsh
# Autoload Functions

__zshrc_autoload() {
local cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/zsh"
local fp="$cache_dir/autoload-cache.zsh"
if [ ! -f $fp ]; then
echo "Compiling autoload directive"
set -x
local -U autoloaded=($XDG_CONFIG_HOME/zshrc.d/autoloaded/[^_]*(xN:t))
mkdir -p "$cache_dir"
echo -e "#!/usr/bin/env zsh\nautoload -Uz ${autoloaded[*]}" > "$fp"
zcompile "$fp" &!
set +x
fi
source "$fp"
}
__zshrc_autoload
unset -f __zshrc_autoload # avoid lambdas so we can use zprof
29 changes: 29 additions & 0 deletions zsh.common/.config/zsh/extras.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env zsh

function __zshrc_load_extra() {
local cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/zsh"
local fp="$cache_dir/extras-cache.zsh"
local -U extra priv list

if [ ! -f "$fp" ]; then
echo "Compiling extra zshrc files"
extra=(
# Meant for external installations, just check if file exists:
/usr/share/autojump/autojump.zs[h](N) # [h] -> POG to activate glob

# Check if the file is executable (so we can deactivate it with chmod)
$HOME/.config/zsh/+local*.zsh(xN)
# ^ Files specific to host, not shared via dotfiles
$HOME/.config/zshrc.d/?*.zsh(xN)
# ^ Files from other program configurations (e.g. TMUX)
)
set -x
mkdir -p "$cache_dir"
cat $extra > "$fp"
zcompile "$fp" &!
set +x
fi
source "$fp"
}
__zshrc_load_extra
unset -f __zshrc_load_extra # avoid lambdas so zprof can be used
10 changes: 0 additions & 10 deletions zsh.common/.config/zshrc.d/autoload.zsh

This file was deleted.

0 comments on commit d7629b9

Please sign in to comment.