1
0
Fork 0
mirror of synced 2024-05-27 12:31:12 -04:00
zimfw/src/zimfw.zsh.erb
Eric Nielsen ed9d08a091
Generate static init.zsh script \o/
to autoloads the functions and sources the scripts, instead of executing
zimfw during startup, and having it always figuring out what do to on
the fly.

This takes out the worry about zimfw interfering with the startup time,
and allows room to add more features to it. So, zstyle was replaced by a
custom zmodule function to define the modules, with the extra ability of
allowing users to set custom fpath paths, autoloaded functions and
sourced scripts per module.
2019-12-03 18:47:12 -05:00

31 lines
775 B
Plaintext

<%# coding: UTF-8 %><%
class Zim
attr_reader :home, :min_zsh_version, :script_filename, :second_stage_guard, :version
def initialize
@home = "${ZDOTDIR:-${HOME}}"
@min_zsh_version = "5.2"
@script_filename = "zimfw.zsh"
@version = "1.0.0-SNAPSHOT"
end
def render(filename)
ERB.new(File.read(filename)).result(binding)
end
def render_all(pattern)
Dir[pattern].sort.map { |filename| render(filename) }.join("\n")
end
def render_escaped(filename)
render(filename).gsub(/(\$[^']|"|`)/, "\\\\\\1")
end
end
zim = Zim.new
%># AUTOMATICALLY GENERATED FILE. EDIT ONLY THE SOURCE FILES AND THEN COMPILE.
# DO NOT DIRECTLY EDIT THIS FILE!
<%= zim.render_all("src/stage1/*.erb") %>
<%= zim.render_all("src/stage2/*.erb") %>
zimfw "${@}"