fetch

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

commit 7aa71b0ad424140f851483571efe981dd01d8003
parent 266e352cc66b14b9b76621623ca87b5cd1c6eda3
Author: Byron Torres <b@torresjrjr>
Date:   Sun, 31 Jan 2021 14:30:21 +0000

Refactor to optimise for reading and patching

Diffstat:
Mfetch | 81++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
1 file changed, 45 insertions(+), 36 deletions(-)

diff --git a/fetch b/fetch @@ -3,35 +3,44 @@ # @torresjrjr <b@torresjrjr.com> -## Colours and cursor util +## Main -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') - -reposition() { printf '\e[%sA\r' "${graphic_y}" ;} -padding() { printf '\e[%sC' "${graphic_x}" ;} +main() { + colours + graphic + reposition + status + echo +} ## Graphic graphic() { #b=':::::::::::::::::::::::::::::::::::::::::::::' # status background - printf "\ -${c2} ~ ${b} -${c2} .-. ${b} -${c2} /\`v\`\\ ${b} -${c2} (/ \\) ${b} -${c2}======\"=\"===< ${b} -${c2} |_| ${b} -${c2} ${b}${c0} -" + printf "${c2}\ + ~ ${b} + .-. ${b} + /\`v\`\\ ${b} + (/ \\) ${b} +======\"=\"===< ${b} + |_| ${b} + ${b} +${c0}" } -graphic_y=$(graphic | wc -l) # height -graphic_x=$(graphic | wc -L) # width + +## Status + +status() { + padding; _title "${c5}%s@%s${c3} %s\n" + padding; _os "${c6}os: ${c0}%s\n" + padding; _kernel "${c6}kernel: ${c0}%s\n" + padding; _shell "${c6}shell: ${c0}%s\n" + padding; _sshd "${c6}sshd: ${c0}%s\n" + padding; _tmux "${c6}tmux: ${c0}%s\n" +# padding; _palette +} ## Statuslines @@ -62,26 +71,26 @@ _tmux() { _palette() { printf "\e[7m$c1 $c2 $c3 $c4 $c5 $c6 \e[m\n" ;} -## Status +## Colours -status() { - padding; _title "${c5}%s@%s${c3} %s\n" - padding; _os "${c6}os: ${c0}%s\n" - padding; _kernel "${c6}kernel: ${c0}%s\n" - padding; _shell "${c6}shell: ${c0}%s\n" - padding; _sshd "${c6}sshd: ${c0}%s\n" - padding; _tmux "${c6}tmux: ${c0}%s\n" -# padding; _palette +colours() { + 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') } -## Run +## Cursor util -main() { - graphic - reposition - status - echo -} +graphic_y=$(graphic | wc -l) # height +graphic_x=$(graphic | wc -L) # width + +reposition() { printf '\e[%sA\r' "${graphic_y}" ;} +padding() { printf '\e[%sC' "${graphic_x}" ;} + + +## Run main