From 4fd3cece95668a48eef11d5877a7f79be338f216 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 24 Sep 2019 10:33:23 +0300 Subject: [PATCH] initial commit --- LICENSE.md | 21 +++++++++++++++++++++ README.md | 3 +++ pfetch | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 LICENSE.md create mode 100644 README.md create mode 100755 pfetch diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..6867a5b --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016-2019 Dylan Araps + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f95ed9e --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# pfetch + +A pretty system information tool written in POSIX `sh`. diff --git a/pfetch b/pfetch new file mode 100755 index 0000000..841051f --- /dev/null +++ b/pfetch @@ -0,0 +1,55 @@ +#!/bin/sh +# shellcheck source=/dev/null +# +# pfetch - Simple POSIX sh fetch script. + +die() { + printf '\033[31;1merror\033[m: %s.\n' "$@" >&2 + exit 1 +} + +log() { + printf '\033[3%s;1m%s\033[m%s%s\n' "$1" "$2" "$3" "${4:-unknown}" +} + +get_os() { + case $kernel_name in + Linux|GNU*) os=linux ;; + + *) + die "Unknown OS detected '$kernel_name'" \ + "Open an issue on GitHub to add support for your OS" + ;; + esac +} + +get_distro() { + case $os in + linux) + . /etc/os-release && distro=$PRETTY_NAME + ;; + esac + + log 1 os " " "$distro" +} + +main() { + # Hide 'stderr' unless the first argument is '-v'. This saves + # polluting the script with '2>/dev/null'. + [ "$1" = -v ] || exec 2>/dev/null + + # Store the output of 'uname' to avoid calling it multiple times + # throughout the script. 'read <