This commit is contained in:
Eric Nielsen 2017-11-03 19:58:27 +00:00 committed by GitHub
commit c3c97cd0ea
12 changed files with 131 additions and 197 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
*.swp
*.zwc
*.zwc.old
custom/

View File

@ -9,44 +9,73 @@ if ! is-at-least 5.2; then
fi
# Define zim location
(( ! ${+ZIM_HOME} )) && export ZIM_HOME="${ZDOTDIR:-${HOME}}/.zim"
(( ! ${+ZIM_HOME} )) && export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
# Source user configuration
if [[ -s "${ZDOTDIR:-${HOME}}/.zimrc" ]]; then
source "${ZDOTDIR:-${HOME}}/.zimrc"
fi
[[ -s ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
load_zim_module() {
local wanted_module
# Autoload module functions
() {
local mod_function
setopt LOCAL_OPTIONS EXTENDED_GLOB
for wanted_module (${zmodules}); do
if [[ -s "${ZIM_HOME}/modules/${wanted_module}/init.zsh" ]]; then
source "${ZIM_HOME}/modules/${wanted_module}/init.zsh"
elif [[ ! -d "${ZIM_HOME}/modules/${wanted_module}" ]]; then
print "No such module \"${wanted_module}\"." >&2
# autoload searches fpath for function locations; add enabled module function paths
fpath=(${ZIM_HOME}/functions.zwc ${ZIM_HOME}/modules/prompt/functions ${fpath})
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/^([_.]*|prompt_*_setup|README*)(-.N:t); do
autoload -Uz ${mod_function}
done
}
# Initialize modules
() {
local zmodule
for zmodule (${zmodules}); do
if [[ -s ${ZIM_HOME}/modules/${zmodule}/init.zsh ]]; then
source ${ZIM_HOME}/modules/${zmodule}/init.zsh
elif [[ ! -d ${ZIM_HOME}/modules/${zmodule} ]]; then
print "No such module \"${zmodule}\"." >&2
fi
done
}
load_zim_function() {
local function_glob='^([_.]*|prompt_*_setup|README*)(-.N:t)'
local mod_function
zmanage() {
local usage="zmanage [action]
Actions:
update Fetch and merge upstream zim commits if possible
info Print zim and system info
issue Create a template for reporting an issue
clean-cache Clean the zim cache
build-cache Rebuild the zim cache
remove *experimental* Remove zim as best we can
reset Reset zim to the latest commit
debug Invoke the trace-zim script which produces logs
help Print this usage message"
# autoload searches fpath for function locations; add enabled module function paths
fpath=(${${zmodules}:+${ZIM_HOME}/modules/${^zmodules}/functions(/FN)} ${fpath})
if (( ${#} != 1 )); then
print ${usage}
return 1
fi
function {
setopt LOCAL_OPTIONS EXTENDED_GLOB
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/${~function_glob}; do
autoload -Uz ${mod_function}
done
}
case ${1} in
update) zsh ${ZIM_HOME}/tools/zim_update
;;
info) zsh ${ZIM_HOME}/tools/zim_info
;;
issue) zsh ${ZIM_HOME}/tools/zim_issue
;;
clean-cache) source ${ZIM_HOME}/tools/zim_clean_cache && print 'Cache cleaned'
;;
build-cache) source ${ZIM_HOME}/tools/zim_build_cache && print 'Cache rebuilt'
;;
remove) zsh ${ZIM_HOME}/tools/zim_remove
;;
reset) zsh ${ZIM_HOME}/tools/zim_reset
;;
debug) zsh ${ZIM_HOME}/modules/debug/functions/trace-zim
;;
*) print ${usage}; return 1
;;
esac
}
# initialize zim modules
load_zim_function
load_zim_module
unset zmodules
unfunction load_zim_{module,function}

44
login_init.zsh Executable file
View File

@ -0,0 +1,44 @@
#
# startup file read in interactive login shells
#
# The following code helps us by optimizing the existing framework.
# This includes zcompile, zcompdump, etc.
#
(
local file
local zmodule
setopt LOCAL_OPTIONS EXTENDED_GLOB
autoload -U zrecompile
# zcompile the completion cache; siginificant speedup
zrecompile -pq ${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}
# zcompile .zshrc
zrecompile -pq ${ZDOTDIR:-${HOME}}/.zshrc
# zcompile enabled module autoloaded functions
zrecompile -pq ${ZIM_HOME}/functions ${ZIM_HOME}/modules/${^zmodules}/functions/^([_.]*|prompt_*_setup|README*|*.zwc|*.zwc.old)(-.N)
# zcompile enabled module init scripts
for zmodule (${zmodules}); do
zrecompile -pq ${ZIM_HOME}/modules/${zmodule}/init.zsh
done
# zcompile all prompt setup scripts
for file in ${ZIM_HOME}/modules/prompt/functions/prompt_*_setup; do
zrecompile -pq ${file}
done
# syntax-highlighting
for file in ${ZIM_HOME}/modules/syntax-highlighting/external/highlighters/**^test-data/*.zsh; do
zrecompile -pq ${file}
done
zrecompile -pq ${ZIM_HOME}/modules/syntax-highlighting/external/zsh-syntax-highlighting.zsh
# zsh-histery-substring-search
zrecompile -pq ${ZIM_HOME}/modules/history-substring-search/external/zsh-history-substring-search.zsh
) &!

View File

@ -21,17 +21,6 @@ autoload -Uz compinit && compinit -C -d "${ZDOTDIR:-${HOME}}/${zcompdump_file:-.
# set any compdefs
source ${0:h}/compdefs.zsh
{
# zcomple the .zcompdump in the background
zcompdump=${ZDOTDIR:-${HOME}}/.zcompdump
if [[ -s ${zcompdump} && ( ! -s ${zcompdump}.zwc || ${zcompdump} -nt ${zcompdump}.zwc) ]]; then
zcompile ${zcompdump}
fi
unset zcompdump
} &!
#
# zsh options

View File

@ -1,21 +0,0 @@
Meta
====
Provides aliases and functions for management of the zim framework, specifically `zmanage`
Usage
-----
`zmanage [arg]`
| Action | Description |
| ----------- | --------------------------------------------------- |
| update | Fetches and merges upstream zim commits if possible |
| info | Prints zim and system info |
| issue | Create a template for reporting an issue |
| clean-cache | Clean the zim cache |
| build-cache | Rebuild the zim cache |
| remove | *experimental* Remove zim as best we can |
| reset | Reset zim to the latest commit |
| help | Print this usage message |
| debug | Invokes the trace-zim script which produces logs |

View File

@ -1,40 +0,0 @@
local usage="${0} [action]
Actions:
| update | Fetches and merges upstream zim commits if possible |
| info | Prints zim and system info |
| issue | Create a template for reporting an issue |
| clean-cache | Clean the zim cache |
| build-cache | Rebuild the zim cache |
| remove | *experimental* Remove zim as best we can |
| reset | Reset zim to the latest commit |
| help | Print this usage message |
| debug | Invokes the trace-zim script which produces logs |"
if (( ${#} != 1 )); then
print ${usage}
return 1
fi
local tools
tools="${ZIM_HOME}/tools"
case ${1} in
update) zsh ${tools}/zim_update
;;
info) zsh ${tools}/zim_info
;;
issue) zsh ${tools}/zim_issue
;;
clean-cache) zsh ${tools}/zim_clean_cache && print 'Cleaned cache'
;;
build-cache) source ${tools}/zim_build_cache && print 'Rebuilt cache'
;;
remove) zsh ${tools}/zim_remove
;;
reset) zsh ${tools}/zim_reset
;;
debug) zsh ${ZIM_HOME}/modules/debug/functions/trace-zim
;;
*) print ${usage}
;;
esac

View File

@ -11,7 +11,7 @@
# Select what modules you would like enabled.
# The second line of modules may depend on options set by modules in the first
# line. These dependencies are noted on the respective module's README.md.
zmodules=(directory environment git git-info history input utility meta custom \
zmodules=(directory environment git git-info history input utility custom \
syntax-highlighting history-substring-search prompt completion)

View File

@ -1,59 +1,8 @@
#
# startup file read in interactive login shells
#
# The following code helps us by optimizing the existing framework.
# This includes zcompile, zcompdump, etc.
# User configuration sourced by login shells
#
(
# Function to determine the need of a zcompile. If the .zwc file
# does not exist, or the base file is newer, we need to compile.
# These jobs are asynchronous, and will not impact the interactive shell
zcompare() {
if [[ -s ${1} && ( ! -s ${1}.zwc || ${1} -nt ${1}.zwc ) ]]; then
zcompile ${1}
fi
}
local zim_mods=${ZIM_HOME}/modules
setopt EXTENDED_GLOB
# zcompile the completion cache; siginificant speedup.
for file in ${ZDOTDIR:-${HOME}}/.zcomp^(*.zwc)(.); do
zcompare ${file}
done
# zcompile .zshrc
zcompare ${ZDOTDIR:-${HOME}}/.zshrc
# zcompile some light module init scripts
zcompare ${zim_mods}/git/init.zsh
zcompare ${zim_mods}/git-info/init.zsh
zcompare ${zim_mods}/utility/init.zsh
zcompare ${zim_mods}/pacman/init.zsh
zcompare ${zim_mods}/spectrum/init.zsh
zcompare ${zim_mods}/completion/init.zsh
zcompare ${zim_mods}/fasd/init.zsh
# zcompile all .zsh files in the custom module
for file in ${zim_mods}/custom/**/^(README.md|*.zwc)(.); do
zcompare ${file}
done
# zcompile all autoloaded functions
for file in ${zim_mods}/**/functions/^(*.zwc)(.); do
zcompare ${file}
done
# syntax-highlighting
for file in ${zim_mods}/syntax-highlighting/external/highlighters/**^test-data/*.zsh; do
zcompare ${file}
done
zcompare ${zim_mods}/syntax-highlighting/external/zsh-syntax-highlighting.zsh
# zsh-histery-substring-search
zcompare ${zim_mods}/history-substring-search/external/zsh-history-substring-search.zsh
) &!
# Initialize zim
[[ -s ${ZIM_HOME}/login_init.zsh ]] && source ${ZIM_HOME}/login_init.zsh

View File

@ -4,11 +4,8 @@
# User configuration sourced by interactive shells
#
# Change default zim location
# Change default zim location
export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
# Source zim
if [[ -s ${ZIM_HOME}/init.zsh ]]; then
source ${ZIM_HOME}/init.zsh
fi
# Start zim
[[ -s ${ZIM_HOME}/init.zsh ]] && source ${ZIM_HOME}/init.zsh

View File

@ -2,4 +2,6 @@
# zim_build_cache - rebuilds the zim cache
#
source ${ZIM_HOME}/templates/zlogin
source ${ZIM_HOME}/login_init.zsh
print 'To rebuild the completion cache, please restart your terminal'

View File

@ -2,7 +2,6 @@
# zim_clean_cache - removes all zcompiled files
#
find ${ZIM_HOME} -iname '*.zwc' | xargs rm
rm -f ${ZDOTDIR:-${HOME}}/.{zshrc.zwc,zcompdump,zcompdump.zwc}
print 'To rebuild the completion cache, please restart your terminal'
find ${ZIM_HOME} \( -name '*.zwc' -or -name '*.zwc.old' \) -delete
rm -f ${ZDOTDIR:-${HOME}}/.zshrc.zwc{,.old}
rm -f ${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}{,.zwc{,.old}}

View File

@ -27,40 +27,25 @@ fi
cd ${ZIM_HOME}
# collect sys info
git_dirty=$(command git status --porcelain 2>/dev/null | tail -n1)
git_ref=$(command git rev-parse --short HEAD)
zsh_version=$(zsh --version)
operating_sys=$(uname -a)
local git_dirty=$(command git status --porcelain 2>/dev/null | tail -n1)
local zim_info=$(zsh tools/zim_info)
print "Environment Info
----------------
${zim_info}
Description
-----------
${user_desc}
# we're going to template and build the issue here (as an array for convenience)
Steps to Reproduce
------------------
${user_reproduce}
issue_md=("Environment Info"
"----------------"
"- Zim commit ref: ${git_ref}"
"- Zsh version: ${zsh_version}"
"- Operating System Info: ${operating_sys}"
""
"Description"
"-----------"
"${user_desc}"
""
"Steps to Reproduce"
"------------------"
"${user_reproduce}"
""
"Images or other Information"
"---------------------------"
""
)
Images or other Information
---------------------------
"
# print the output:
# hack: we need to iterate over the elements to capture the blank spaces (to print newlines)
for (( i=0; i < ${#issue_md[@]}; i++ )); do
printf '%s\n' ${issue_md[i]}
done
# if we have a dirty git, report it
if [[ -n ${git_dirty} ]]; then