From 31590401f2345a2b5b75fac1c5869dbd5fb5922f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 24 Sep 2019 11:13:40 +0300 Subject: [PATCH] pfetch: add support for user@host --- pfetch | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pfetch b/pfetch index 2492afe..2c4148b 100755 --- a/pfetch +++ b/pfetch @@ -23,6 +23,27 @@ get_os() { esac } +get_title() { + case $os in + linux) + read -r hostname < /proc/sys/kernel/hostname + ;; + esac + + # Username is retrieved by first checking '$USER' with a fallback + # to the 'whoami' command. + # + # Hostname is retrieved by first checking '$HOSTNAME' with a fallback + # to the OS specific detection above and finally an additional fallback + # to the 'hostname' command. + # + # Disable the warning about '$HOSTNAME' being undefined + # in POSIX sh as it is intended for allowing the user to + # overwrite the value on invocation. + # shellcheck disable=SC2039 + log 1 "${USER:-$(whoami)}" @ "${HOSTNAME:-${hostname:-$(hostname)}}" +} + get_distro() { case $os in linux) @@ -107,6 +128,7 @@ main() { EOF get_os + get_title get_distro get_kernel get_uptime