1
0
Fork 0
mirror of synced 2024-06-18 06:41:08 -04:00
zimfw/src/zimfw.zsh.erb
Eric Nielsen aade4704b1
Generate login_init.zsh file
So we can have the following code in the zlogin template:

    source ${ZIM_HOME}/login_init.zsh -q &!

instead of depending on the zimfw function there. This allows fixing the
issue were a non-interactive login shell currently yields:

    command not found: zimfw.

To fully fix the issue, we also need a new zshenv template containing:

    ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim

Templates will be updated in the install script.
2020-01-02 12:58:04 -05:00

40 lines
972 B
Plaintext

<%
class Zim
attr_reader :home, :min_zsh_version, :script_filename, :version, :ellipsis, :okay, :error, :done, :failed
def initialize
@home = "${ZDOTDIR:-${HOME}}"
@min_zsh_version = "5.2"
@script_filename = "zimfw.zsh"
@version = "1.0.0-SNAPSHOT"
@ellipsis = " ..."
@okay = "%F{green})%f "
@error = "x "
@done = ""
@failed = ""
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
def render_commented(filename)
render(filename).gsub(/^(?=.)/, "# ").gsub(/^$/, "#")
end
end
zim = Zim.new
%># AUTOMATICALLY GENERATED FILE. EDIT ONLY THE SOURCE FILES AND THEN COMPILE.
# DO NOT DIRECTLY EDIT THIS FILE!
<%= zim.render_commented("LICENSE") %>
<%= zim.render_all("src/stage2/*.erb") %>
zimfw "${@}"