aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan Araps <dylan.araps@gmail.com>2019-09-24 11:13:40 +0300
committerDylan Araps <dylan.araps@gmail.com>2019-09-24 11:13:40 +0300
commit31590401f2345a2b5b75fac1c5869dbd5fb5922f (patch)
treeea87193cd1bbbd87c79c1083f7ef7947c18aaa7c
parent70fb22fa5da61703ea93bbe2de817abb712a198c (diff)
downloadpfetch-31590401f2345a2b5b75fac1c5869dbd5fb5922f.tar.gz
pfetch: add support for user@host
-rwxr-xr-xpfetch22
1 files changed, 22 insertions, 0 deletions
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