2019-12-13 07:14:10 -05:00
|
|
|
<%
|
2019-01-22 19:40:43 -05:00
|
|
|
class Zim
|
2021-04-03 10:35:28 -04:00
|
|
|
attr_reader :version, :home, :min_zsh_version, :startup_files_glob, :url_regex,
|
|
|
|
:clear_line, :ellipsis, :okay, :warn, :error, :done, :failed
|
2019-01-22 19:40:43 -05:00
|
|
|
|
|
|
|
def initialize
|
2021-11-08 12:03:49 -05:00
|
|
|
@version = "1.6.1"
|
2019-01-22 19:40:43 -05:00
|
|
|
@home = "${ZDOTDIR:-${HOME}}"
|
|
|
|
@min_zsh_version = "5.2"
|
2020-01-08 08:19:52 -05:00
|
|
|
@startup_files_glob = ".z(shenv|profile|shrc|login|logout)"
|
2021-04-03 10:35:28 -04:00
|
|
|
# Matches {ssh,http,https,git}://{user@,}host/org/repo and {user@,}host:org/repo
|
|
|
|
# but not file:///path/to/repo or /path/to/repo
|
|
|
|
# ${match[3]} contains host, and ${match[4]} contains org/repo
|
|
|
|
@url_regex = "^([^:@/]+://)?([^@]+@)?([^:/]+)[:/]([^/]+/[^/]+)/?$"
|
|
|
|
@clear_line = "$'\\E[2K\\r'"
|
2019-12-13 07:14:10 -05:00
|
|
|
@ellipsis = " ..."
|
|
|
|
@okay = "%F{green})%f "
|
2020-05-25 15:01:00 -04:00
|
|
|
@warn = "! "
|
2019-12-13 07:14:10 -05:00
|
|
|
@error = "x "
|
|
|
|
@done = ""
|
|
|
|
@failed = ""
|
2019-01-22 19:40:43 -05:00
|
|
|
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
|
|
|
|
|
2021-04-03 10:35:28 -04:00
|
|
|
def render_commented(filename)
|
|
|
|
render(filename).gsub(/^(?=.)/, "# ").gsub(/^$/, "#")
|
|
|
|
end
|
|
|
|
|
2019-01-22 19:40:43 -05:00
|
|
|
def render_escaped(filename)
|
2020-06-05 23:09:23 -04:00
|
|
|
render(filename).gsub(/(?=\$[^']|"|`)/, "\\\\").gsub(/#\{/, "$\{")
|
2019-01-22 19:40:43 -05:00
|
|
|
end
|
2019-12-08 20:03:45 -05:00
|
|
|
|
2021-04-03 10:35:28 -04:00
|
|
|
def render_tools(pattern, var)
|
|
|
|
Dir[pattern].sort.map { |filename|
|
|
|
|
" #{File.basename(filename, ".zsh.erb")}) #{var}=\"#{render_escaped(filename)}\" ;;"
|
|
|
|
}.join("\n")
|
2019-12-08 20:03:45 -05:00
|
|
|
end
|
2019-01-22 19:40:43 -05:00
|
|
|
end
|
|
|
|
zim = Zim.new
|
|
|
|
%># AUTOMATICALLY GENERATED FILE. EDIT ONLY THE SOURCE FILES AND THEN COMPILE.
|
|
|
|
# DO NOT DIRECTLY EDIT THIS FILE!
|
|
|
|
|
2019-12-08 20:03:45 -05:00
|
|
|
<%= zim.render_commented("LICENSE") %>
|
2019-12-01 16:00:47 -05:00
|
|
|
<%= zim.render_all("src/stage2/*.erb") %>
|
2021-09-20 22:14:12 -04:00
|
|
|
if [[ ${functrace[1]} == zmodule:* ]]; then
|
|
|
|
zmodule "${@}"
|
|
|
|
else
|
|
|
|
zimfw "${@}"
|
|
|
|
fi
|