2023-11-16 22:10:51 -06:00
|
|
|
<?shp
|
|
|
|
|
|
|
|
gen_titlebar() {
|
|
|
|
__tb_title="${1:-${TB_TITLE:-untitled}}"
|
|
|
|
__tb_color="${2:-${TB_COLOR:-random}}"
|
|
|
|
# make sure this matches /src/style/titlebars.css
|
2024-03-13 20:37:38 -05:00
|
|
|
set -- teal brown lgrey dgrey lblue purple white lblue dblue green pink
|
2023-11-16 22:10:51 -06:00
|
|
|
if [ "$__tb_color" = "random" ]; then
|
2024-01-10 18:13:15 -06:00
|
|
|
# gotta start with nonzero so printf doesn't interpret as octal
|
|
|
|
__d="1$(tr -Cd '[:digit:]' < /dev/urandom | dd bs=1 count=3 2>/dev/null)"
|
2023-11-16 22:10:51 -06:00
|
|
|
eval '__tb_color=${'$((__d % $# + 1))'}'
|
|
|
|
fi
|
|
|
|
printf '<div class="titlebar tb-%s" aria-hidden="true">
|
|
|
|
<span class="tbl" title="%s"></span>
|
|
|
|
<span class="tbr"></span>
|
2024-03-13 20:37:38 -05:00
|
|
|
</div>\n' "$__tb_color" "$__tb_title"
|
2023-11-16 22:10:51 -06:00
|
|
|
}
|
2024-03-31 15:04:49 -05:00
|
|
|
|
|
|
|
# get creation date via git, outputs in unix timestamp
|
|
|
|
# unless $2 is given. then it's as that format
|
|
|
|
# I don't actually use these two functions but I'm putting them here
|
|
|
|
# so I don't forget and just in case I *do* use them in the future
|
|
|
|
get_creation_time() {
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
git log --follow --date=unix --format=%ad --reverse -- "$1" | head -n 1
|
|
|
|
else
|
|
|
|
date -d "@$(git log --follow --date=unix --format=%ad --reverse -- "$1" | head -n 1)" +"$2"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# get last modified date via git, outputs in unix timestamp
|
|
|
|
get_modified_time() {
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
git log --date=unix --format=%ad -1 -- "$1"
|
|
|
|
else
|
|
|
|
date -d "@$(git log --date=unix --format=%ad -1 -- "$1")" +"$2"
|
|
|
|
fi
|
|
|
|
}
|