fetch

A MSYS2-compatible sys-info prompt
Log | Files | Refs | README | LICENSE

commit 595e81e45de7df20eb7d38ebd085c5e2f8c23051
parent 828fbbc2f6ecd53d43d08b401d616861df8bd564
Author: Byron Torres <b@torresjrjr>
Date:   Mon, 23 Nov 2020 23:13:48 +0000

Show graphic initially; Use mktemp

Diffstat:
Mfetch | 54+++++++++++++++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 25 deletions(-)

diff --git a/fetch b/fetch @@ -1,7 +1,30 @@ #!/bin/sh # A fetch for MSYS2 on Windows. # @torresjrjr -printf '...\r' + +printf '...\r' # initial wait + +## Prepare colours (and palette if used) +c0=$(printf '\e[0m' ) +c1=$(printf '\e[31m'); c2=$(printf '\e[32m') +c3=$(printf '\e[33m'); c4=$(printf '\e[34m') +c5=$(printf '\e[35m'); c6=$(printf '\e[36m') +c7=$(printf '\e[37m'); c8=$(printf '\e[38m') +palette=$(printf "\e[7m$c1 $c1 $c2 $c2 $c3 $c3 $c4 $c4 $c5 $c5 $c6 $c6 \e[m") + +## Create graphic +d='\t' # delimiter +graphic=$(printf "\ +${c2} ~ ${d} +${c2} .-. ${d} +${c2} /\`v\`\\ ${d} +${c2} (/ \\) ${d} +${c2}======\"=\"===< ${d} +${c2} |_| ${d} +${c2} ${d}${c0} +") + +printf '%s' "${graphic}" # initial graphic ## Get variables date=$(date -R) @@ -22,33 +45,13 @@ then tmux ls \ | sed \ -e 's/(created[^)]*)//' -e 's/(attached)/@/' \ - -e 's/windows/w/' -e 's/ //g' \ + -e 's/windows/w/' -e 's/ //g' \ | paste -s ) else tmux_sessions='--' fi -## Prepare colours (and palette if used) -c0=$(printf '\e[0m' ) -c1=$(printf '\e[31m'); c2=$(printf '\e[32m') -c3=$(printf '\e[33m'); c4=$(printf '\e[34m') -c5=$(printf '\e[35m'); c6=$(printf '\e[36m') -c7=$(printf '\e[37m'); c8=$(printf '\e[38m') -palette=$(printf "\e[7m$c1 $c1 $c2 $c2 $c3 $c3 $c4 $c4 $c5 $c5 $c6 $c6 \e[m") - -## Create graphic -d='\t' # delimiter -graphic=$(printf "\ -${c2} ~ ${d} -${c2} .-. ${d} -${c2} /\`v\`\\ ${d} -${c2} (/ \\) ${d} -${c2}======\"=\"===< ${d} -${c2} |_| ${d} -${c2} ${d}${c0} -") - ## Create status status="\ ${c5}${user}@${host}${c3} ${date} @@ -60,8 +63,9 @@ ${c6}tmux: ${c0}${tmux_sessions} " ## Print fetch -tmp=/tmp/fetch_tmp -printf '%s' "${graphic}" > "${tmp}/graphic" -printf '%s\n' "$( printf '%s' "${status}" | paste -d '' "${tmp}/graphic" - )" +tmpfile=$(mktemp) +printf '%s' "${graphic}" > "${tmpfile}" +clear +printf '%s\n' "$( printf '%s' "${status}" | paste -d '' "${tmpfile}" - )" # @torresjrjr