fetch

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

commit 15db55b728791803d9a022525bfa6e54ac5a7c3a
parent 196438124ef4244b872dd0bd7bb5099e0a7e1139
Author: Byron Torres <b@torresjrjr>
Date:   Fri, 13 Nov 2020 23:41:59 +0000

Initial fetch

Diffstat:
Afetch.sh | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 66 insertions(+), 0 deletions(-)

diff --git a/fetch.sh b/fetch.sh @@ -0,0 +1,66 @@ +#!/bin/sh +# A fetch for MSYS2 on Windows. +# @torresjrjr +printf '...\r' + +## Get variables +shell=${SHELL##*/} +user=${USER} +host=$(hostname) +# see `man uname` +os=$(uname -o) +kernel_name=$(uname -s) +kernel_release=$(uname -r) + +sshd_pid=$(ps | grep sshd | awk '{print $1}' | paste -s) +sshd_pid=${sshd_pid:---} + +if ps | grep tmux >/dev/null +then + tmux_sessions=$( + tmux ls \ + | sed \ + -e 's/(created[^)]*)//' -e 's/(attached)/@/g' \ + -e 's/windows/w/g' -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} +${c6}os: ${c0}${os} +${c6}kernel: ${c0}${kernel_name} ${kernel_release} +${c6}shell: ${c0}${shell} +${c6}sshd: ${c0}${sshd_pid} +${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" - )" + +# @torresjrjr