-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_page.sh
executable file
·51 lines (41 loc) · 1.46 KB
/
generate_page.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
set -xueo pipefail
escape_url() {
local image_path="$1"
image_path="${image_path// /%20}"
echo "${image_path}"
}
readonly ZSH="${HOME}/.antigen/bundles/robbyrussell/oh-my-zsh"
readonly THEMES_DIR="${ZSH}/themes"
readonly THEME_SUFFIX=".zsh-theme"
to_theme_name() {
local -r theme_path="$1"
basename "${theme_path}" "${THEME_SUFFIX}"
}
list_themes() {
for theme_path in "${THEMES_DIR}/"*"${THEME_SUFFIX}"; do
to_theme_name "${theme_path}"
done
}
echo "## By color preset" > README.md
for color_preset_dir in images/*; do
color_preset="$(basename "${color_preset_dir}")"
page_path="pages/presets/${color_preset}.md"
for screenshot in "${color_preset_dir}"/*.png; do
theme="$(basename "${screenshot}" .png)"
echo "# \`ZSH_THEME=\"${theme}\"\`"
echo "![Had to be an image :(](/$(escape_url "${screenshot}"))"
done > "${page_path}"
echo "* [${color_preset}]($(escape_url "/${page_path}"))" >> README.md
done
echo "## By theme" >> README.md
list_themes | while read -r theme_name; do
page_path="pages/themes/${theme_name}.md"
for color_preset_dir in "images/"*; do
color_preset="$(basename "${color_preset_dir}")"
screenshot="${color_preset_dir}/${theme_name}.png"
echo "# ${color_preset}"
echo "![Had to be an image :(](/$(escape_url "${screenshot}"))"
done > "${page_path}"
echo "* [${theme_name}]($(escape_url "/${page_path}"))" >> README.md
done