fetch

[sh] MSYS2-compatible system info prompt
git clone https://git.torresjrjr.com/fetch.git
Log | Files | Refs | README | LICENSE

commit b99649b7b2c6dc5b3d31b85cb7e51fe6b759f740
parent d798833f7d84f34b89db70735ee5a842db4e9e3f
Author: Byron Torres <b@torresjrjr.com>
Date:   Fri,  3 Mar 2023 01:47:27 +0000

Improve printf statements

Diffstat:
Mfetch | 26+++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/fetch b/fetch @@ -33,12 +33,12 @@ graphic() { ## Status status() { - padding; _title "${c5}%s@%s ${c3}%s\n" - padding; _os "${c6}os ${c0}%s\n" - padding; _uptime "${c6}uptime ${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; _title "${c5}%s@%s ${c3}%s" + padding; _os "${c6}os ${c0}%s" + padding; _uptime "${c6}uptime ${c0}%s" + padding; _shell "${c6}shell ${c0}%s" + padding; _sshd "${c6}sshd ${c0}%s" + padding; _tmux "${c6}tmux ${c0}%s" # padding; _palette } @@ -46,35 +46,35 @@ status() { ## Statuslines _title() { - env printf "$1" "$(whoami)" "$(uname -n)" "$(date -R)" + env printf "$c0$1\n" "$(whoami)" "$(uname -n)" "$(date -R)" } _os() { [ -r /etc/os-release ] && . /etc/os-release || PRETTY_NAME=$(uname -o) - env printf "$1" "$PRETTY_NAME $(uname -r)" + env printf "$c0$1\n" "$PRETTY_NAME $(uname -r)" } _uptime() { [ -r /proc/uptime ] && { s=$(cat /proc/uptime) s=${s%%.*} days=$(($s / 86400)) hours=$(($s / 3600 % 24)) mins=$(($s / 60 % 60)) since=$(date -d @$(($(date +%s) - $s)) +'%b %d. %H:%M') - env printf "$1" "${days}d ${hours}h ${mins}m -- ${since}" + env printf "$c0$1\n" "${days}d ${hours}h ${mins}m -- ${since}" } || { - env printf "$1" "$(uptime --pretty 2>&- || uptime) -- $(uptime -s)" + env printf "$c0$1\n" "$(uptime --pretty 2>&- || uptime) -- $(uptime -s)" } } _shell() { - env printf "$1" "$(readlink /proc/$PPID/exe) '$SHLVL" + env printf "$c0$1\n" "$(readlink /proc/$PPID/exe) '$SHLVL" } _sshd() { pids=$(ps ax | awk '/sshd[^@]*@pts/ || /sshd$/ {printf $NF " "}') - env printf "$1" "${pids:---}" + env printf "$c0$1\n" "${pids:---}" } _tmux() { ps ax | grep -v 'grep' | grep -q 'tmux' && tmux_sessions=$( tmux ls -F "#{session_created} #{?session_attached,$ul,}#S:#{session_windows}$c0" \ | sort | awk '{printf $2 " "}' | xargs -0 printf ) - env printf "$1" "${tmux_sessions:---}" + env printf "$c0$1\n" "${tmux_sessions:---}" } _palette() { env printf "$rv$c1 $c2 $c3 $c4 $c5 $c6 $c0\n"