mirror of
https://github.com/dylanaraps/pfetch.git
synced 2026-01-02 16:02:12 +01:00
Compare commits
37 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d706ec7a01 | ||
|
|
c9d961836c | ||
|
|
3a8ac8c53d | ||
|
|
fcd62e9043 | ||
|
|
02a9bd84af | ||
|
|
a9af270b96 | ||
|
|
9985e6cfe9 | ||
|
|
0977e5f1a1 | ||
|
|
8ff9d722b5 | ||
|
|
ca4004de90 | ||
|
|
ee6e1bd390 | ||
|
|
c888f4cdca | ||
|
|
1363a973d4 | ||
|
|
7e70668ce7 | ||
|
|
935fd295dd | ||
|
|
5648839b55 | ||
|
|
d79c2f20d5 | ||
|
|
24e063479a | ||
|
|
3a562917c3 | ||
|
|
300f31c5cd | ||
|
|
f4bb7a3da8 | ||
|
|
09c179f6f5 | ||
|
|
b85ec5657d | ||
|
|
6b46e941cd | ||
|
|
180c00173a | ||
|
|
be6b5ae5ed | ||
|
|
c6f46d5428 | ||
|
|
a43a697551 | ||
|
|
8b801b8b50 | ||
|
|
c9c27ba54b | ||
|
|
090fe64dec | ||
|
|
fddfe5435c | ||
|
|
a7d1a6d980 | ||
|
|
6c50390f78 | ||
|
|
ec69fcb195 | ||
|
|
599db8dc83 | ||
|
|
7d343f9d62 |
4
.github/workflows/main.yml
vendored
4
.github/workflows/main.yml
vendored
@@ -6,4 +6,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Run shellcheck.
|
- name: Run shellcheck.
|
||||||
run: shellcheck pfetch
|
run: |
|
||||||
|
shellcheck pfetch
|
||||||
|
sh pfetch
|
||||||
|
|||||||
49
README.md
49
README.md
@@ -21,12 +21,41 @@ _/\ __)/_) pkgs 130
|
|||||||
|
|
||||||
## OS support
|
## OS support
|
||||||
|
|
||||||
- [x] Linux (A myriad of distributions)
|
- Linux
|
||||||
- [x] MacOS
|
- Alpine Linux
|
||||||
- [x] OpenBSD
|
- Arch Linux
|
||||||
- [x] FreeBSD
|
- Arco Linux
|
||||||
- [x] NetBSD
|
- Artix Linux
|
||||||
- [x] Haiku
|
- CentOS
|
||||||
|
- Debian
|
||||||
|
- Elementary
|
||||||
|
- Fedora
|
||||||
|
- Gentoo
|
||||||
|
- Guix
|
||||||
|
- Hyperbola
|
||||||
|
- KISS Linux
|
||||||
|
- Linux Lite
|
||||||
|
- Linux Mint
|
||||||
|
- Mageia
|
||||||
|
- Manjaro
|
||||||
|
- MX Linux
|
||||||
|
- NixOS
|
||||||
|
- OpenSUSE
|
||||||
|
- Parabola
|
||||||
|
- Pop!\_OS
|
||||||
|
- PureOS
|
||||||
|
- Slackware
|
||||||
|
- Ubuntu
|
||||||
|
- Void Linux
|
||||||
|
- BSD
|
||||||
|
- DragonflyBSD
|
||||||
|
- FreeBSD
|
||||||
|
- NetBSD
|
||||||
|
- OpenBSD
|
||||||
|
- MacOS
|
||||||
|
- Haiku
|
||||||
|
- Minix
|
||||||
|
- Solaris
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
@@ -38,8 +67,8 @@ _/\ __)/_) pkgs 130
|
|||||||
- [ ] Window manager ([#13](https://github.com/dylanaraps/pfetch/pull/13))
|
- [ ] Window manager ([#13](https://github.com/dylanaraps/pfetch/pull/13))
|
||||||
- [ ] ???
|
- [ ] ???
|
||||||
- [ ] Expand operating system support.
|
- [ ] Expand operating system support.
|
||||||
- [ ] Solaris ([#5](https://github.com/dylanaraps/pfetch/issues/5))
|
- [x] Solaris ([#5](https://github.com/dylanaraps/pfetch/issues/5))
|
||||||
- [ ] MINIX ([#6](https://github.com/dylanaraps/pfetch/issues/6))
|
- [x] MINIX ([#6](https://github.com/dylanaraps/pfetch/issues/6))
|
||||||
- [ ] AIX ([#7](https://github.com/dylanaraps/pfetch/issues/7))
|
- [ ] AIX ([#7](https://github.com/dylanaraps/pfetch/issues/7))
|
||||||
- [ ] IRIX ([#8](https://github.com/dylanaraps/pfetch/issues/8))
|
- [ ] IRIX ([#8](https://github.com/dylanaraps/pfetch/issues/8))
|
||||||
- [ ] FreeMiNT ([#9](https://github.com/dylanaraps/pfetch/issues/9))
|
- [ ] FreeMiNT ([#9](https://github.com/dylanaraps/pfetch/issues/9))
|
||||||
@@ -60,13 +89,13 @@ _/\ __)/_) pkgs 130
|
|||||||
# Valid: space separated string
|
# Valid: space separated string
|
||||||
#
|
#
|
||||||
# OFF by default: shell palette
|
# OFF by default: shell palette
|
||||||
PF_INFO="ascii title distro host kernel uptime pkgs memory"
|
PF_INFO="ascii title os host kernel uptime pkgs memory"
|
||||||
|
|
||||||
# Example: Only ASCII.
|
# Example: Only ASCII.
|
||||||
PF_INFO="ascii"
|
PF_INFO="ascii"
|
||||||
|
|
||||||
# Example: Only Information.
|
# Example: Only Information.
|
||||||
PF_INFO="title distro host kernel uptime pkgs memory"
|
PF_INFO="title os host kernel uptime pkgs memory"
|
||||||
|
|
||||||
# Separator between info name and info data.
|
# Separator between info name and info data.
|
||||||
# Default: unset
|
# Default: unset
|
||||||
|
|||||||
228
pfetch
228
pfetch
@@ -64,7 +64,7 @@ log() {
|
|||||||
|
|
||||||
# Use 'set --' as a means of stripping all leading and trailing
|
# Use 'set --' as a means of stripping all leading and trailing
|
||||||
# white-space from the info string. This also normalizes all
|
# white-space from the info string. This also normalizes all
|
||||||
# whitespace inside of the string.
|
# white-space inside of the string.
|
||||||
#
|
#
|
||||||
# Disable the shellcheck warning for word-splitting
|
# Disable the shellcheck warning for word-splitting
|
||||||
# as it's safe and intended ('set -f' disables globbing).
|
# as it's safe and intended ('set -f' disables globbing).
|
||||||
@@ -95,13 +95,13 @@ log() {
|
|||||||
printf '[3%sm%s[m\n' "${PF_COL2-7}" "$info"
|
printf '[3%sm%s[m\n' "${PF_COL2-7}" "$info"
|
||||||
|
|
||||||
# Keep track of the number of times 'log()' has been run.
|
# Keep track of the number of times 'log()' has been run.
|
||||||
: $((info_height+=1))
|
info_height=$((${info_height:-0} + 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
get_title() {
|
get_title() {
|
||||||
# Username is retrieved by first checking '$USER' with a fallback
|
# Username is retrieved by first checking '$USER' with a fallback
|
||||||
# to the 'whoami' command.
|
# to the 'id -un' command.
|
||||||
user=${USER:-$(whoami)}
|
user=${USER:-$(id -un)}
|
||||||
|
|
||||||
# Hostname is retrieved by first checking '$HOSTNAME' with a fallback
|
# Hostname is retrieved by first checking '$HOSTNAME' with a fallback
|
||||||
# to the 'hostname' command.
|
# to the 'hostname' command.
|
||||||
@@ -154,23 +154,27 @@ get_os() {
|
|||||||
if command -v lsb_release; then
|
if command -v lsb_release; then
|
||||||
distro=$(lsb_release -sd)
|
distro=$(lsb_release -sd)
|
||||||
|
|
||||||
# lsb_release sometimes adds quotes around the output,
|
|
||||||
# this simply remove quotes from the start/end if they
|
|
||||||
# exist.
|
|
||||||
distro=${distro##\"}
|
|
||||||
distro=${distro%%\"}
|
|
||||||
|
|
||||||
else
|
else
|
||||||
# Disable warning about shellcheck not being able
|
# This used to be a simple '. /etc/os-release' but I believe
|
||||||
# to read '/etc/os-release'. This is fine.
|
# this is insecure as we blindly execute whatever is in the
|
||||||
# shellcheck source=/dev/null
|
# file. This parser instead simply handles 'key=val', treating
|
||||||
. /etc/os-release && distro=$PRETTY_NAME
|
# the file contents as plain-text.
|
||||||
|
while IFS='=' read -r key val; do
|
||||||
|
case $key in
|
||||||
|
PRETTY_NAME) distro=$val ;;
|
||||||
|
esac
|
||||||
|
done < /etc/os-release
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# 'os-release' and 'lsb_release' sometimes add quotes
|
||||||
|
# around the distribution name, strip them.
|
||||||
|
distro=${distro##[\"\']}
|
||||||
|
distro=${distro%%[\"\']}
|
||||||
|
|
||||||
# Special cases for (independent) distributions which
|
# Special cases for (independent) distributions which
|
||||||
# don't follow any os-release/lsb standards whatsoever.
|
# don't follow any os-release/lsb standards whatsoever.
|
||||||
command -v crux && distro=$(crux)
|
command -v crux && distro=$(crux)
|
||||||
command -v guix && distro='Guix System'
|
command -v guix && distro='Guix System'
|
||||||
|
|
||||||
# Check to see if Linux is running in Windows 10 under
|
# Check to see if Linux is running in Windows 10 under
|
||||||
# WSL (Windows subsystem for Linux) and append a string
|
# WSL (Windows subsystem for Linux) and append a string
|
||||||
@@ -234,8 +238,22 @@ get_os() {
|
|||||||
|
|
||||||
Haiku)
|
Haiku)
|
||||||
# Haiku uses 'uname -v' for version information
|
# Haiku uses 'uname -v' for version information
|
||||||
# instead of 'uname -r'.
|
# instead of 'uname -r' which only prints '1'.
|
||||||
distro="Haiku $(uname -v)"
|
distro=$(uname -sv)
|
||||||
|
;;
|
||||||
|
|
||||||
|
Minix|DragonFly)
|
||||||
|
distro="$os $kernel"
|
||||||
|
|
||||||
|
# Minix and DragonFly don't support the escape
|
||||||
|
# sequences used, clear the exit trap.
|
||||||
|
trap '' EXIT
|
||||||
|
;;
|
||||||
|
|
||||||
|
SunOS)
|
||||||
|
# Grab the first line of the '/etc/release' file
|
||||||
|
# discarding everything after '('.
|
||||||
|
IFS='(' read -r distro _ < /etc/release
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
@@ -250,7 +268,7 @@ get_kernel() {
|
|||||||
case $os in
|
case $os in
|
||||||
# Don't print kernel output on some systems as the
|
# Don't print kernel output on some systems as the
|
||||||
# OS name includes it.
|
# OS name includes it.
|
||||||
*BSD*|Haiku) ;;
|
*BSD*|Haiku|Minix) ;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
# '$kernel' is the cached output of 'uname -r'.
|
# '$kernel' is the cached output of 'uname -r'.
|
||||||
@@ -276,7 +294,7 @@ get_host() {
|
|||||||
host="$name $version $model"
|
host="$name $version $model"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
Darwin*|FreeBSD*)
|
Darwin*|FreeBSD*|DragonFly*)
|
||||||
host=$(sysctl -n hw.model)
|
host=$(sysctl -n hw.model)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -337,11 +355,11 @@ get_uptime() {
|
|||||||
# converting that data into days, hours and minutes using simple
|
# converting that data into days, hours and minutes using simple
|
||||||
# math.
|
# math.
|
||||||
case $os in
|
case $os in
|
||||||
Linux*)
|
Linux*|Minix*)
|
||||||
IFS=. read -r s _ < /proc/uptime
|
IFS=. read -r s _ < /proc/uptime
|
||||||
;;
|
;;
|
||||||
|
|
||||||
Darwin*|*BSD*)
|
Darwin*|*BSD*|DragonFly*)
|
||||||
s=$(sysctl -n kern.boottime)
|
s=$(sysctl -n kern.boottime)
|
||||||
|
|
||||||
# Extract the uptime in seconds from the following output:
|
# Extract the uptime in seconds from the following output:
|
||||||
@@ -359,6 +377,19 @@ get_uptime() {
|
|||||||
# regular seconds.
|
# regular seconds.
|
||||||
s=$(($(system_time) / 1000000))
|
s=$(($(system_time) / 1000000))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
SunOS)
|
||||||
|
# Split the output of 'kstat' on '.' and any white-space
|
||||||
|
# which exists in the command output.
|
||||||
|
#
|
||||||
|
# The output is as follows:
|
||||||
|
# unix:0:system_misc:snaptime 14809.906993005
|
||||||
|
#
|
||||||
|
# The parser extracts: ^^^^^
|
||||||
|
IFS=' .' read -r _ s _ <<-EOF
|
||||||
|
$(kstat -p unix:0:system_misc:snaptime)
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Convert the uptime from seconds into days, hours and minutes.
|
# Convert the uptime from seconds into days, hours and minutes.
|
||||||
@@ -399,25 +430,20 @@ get_pkgs() {
|
|||||||
case $os in
|
case $os in
|
||||||
Linux*)
|
Linux*)
|
||||||
# Commands which print packages one per line.
|
# Commands which print packages one per line.
|
||||||
has kiss && kiss l
|
|
||||||
has bonsai && bonsai list
|
has bonsai && bonsai list
|
||||||
has pacman-key && pacman -Qq
|
has pacman-key && pacman -Qq
|
||||||
has dpkg && dpkg-query -f '.\n' -W
|
has dpkg && dpkg-query -f '.\n' -W
|
||||||
has rpm && rpm -qa
|
has rpm && rpm -qa
|
||||||
has xbps-query && xbps-query -l
|
has xbps-query && xbps-query -l
|
||||||
has apk && apk info
|
has apk && apk info
|
||||||
|
has guix && guix package --list-installed
|
||||||
|
|
||||||
# Directories containing packages.
|
# Directories containing packages.
|
||||||
|
has kiss && printf '%s\n' /var/db/kiss/installed/*/
|
||||||
has brew && printf '%s\n' "$(brew --cellar)/"*
|
has brew && printf '%s\n' "$(brew --cellar)/"*
|
||||||
has emerge && printf '%s\n' /var/db/pkg/*/*/
|
has emerge && printf '%s\n' /var/db/pkg/*/*/
|
||||||
has pkgtool && printf '%s\n' /var/log/packages/*
|
has pkgtool && printf '%s\n' /var/log/packages/*
|
||||||
|
|
||||||
# GUIX requires two commands.
|
|
||||||
has guix && {
|
|
||||||
guix package -p /run/current-system/profile -I
|
|
||||||
guix package -I
|
|
||||||
}
|
|
||||||
|
|
||||||
# NIX requires two commands.
|
# NIX requires two commands.
|
||||||
has nix-store && {
|
has nix-store && {
|
||||||
nix-store -q --requisites /run/current-system/sw
|
nix-store -q --requisites /run/current-system/sw
|
||||||
@@ -434,7 +460,7 @@ get_pkgs() {
|
|||||||
has brew && printf '%s\n' /usr/local/Cellar/*
|
has brew && printf '%s\n' /usr/local/Cellar/*
|
||||||
;;
|
;;
|
||||||
|
|
||||||
FreeBSD*)
|
FreeBSD*|DragonFly*)
|
||||||
pkg info
|
pkg info
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -449,6 +475,15 @@ get_pkgs() {
|
|||||||
Haiku)
|
Haiku)
|
||||||
printf '%s\n' /boot/system/package-links/*
|
printf '%s\n' /boot/system/package-links/*
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
Minix)
|
||||||
|
printf '%s\n' /usr/pkg/var/db/pkg/*/
|
||||||
|
;;
|
||||||
|
|
||||||
|
SunOS)
|
||||||
|
has pkginfo && pkginfo -i
|
||||||
|
has pkg && pkg list
|
||||||
|
;;
|
||||||
esac | wc -l
|
esac | wc -l
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -457,14 +492,14 @@ get_pkgs() {
|
|||||||
|
|
||||||
get_memory() {
|
get_memory() {
|
||||||
case $os in
|
case $os in
|
||||||
# Used memory is calculated using the following "formula" (Linux):
|
# Used memory is calculated using the following "formula":
|
||||||
# MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable
|
# MemUsed = MemTotal + Shmem - MemFree - Buffers - Cached - SReclaimable
|
||||||
# Source: https://github.com/KittyKatt/screenFetch/issues/386
|
# Source: https://github.com/KittyKatt/screenFetch/issues/386
|
||||||
Linux*)
|
Linux*)
|
||||||
# Parse the '/proc/meminfo' file splitting on ':' and 'k'.
|
# Parse the '/proc/meminfo' file splitting on ':' and 'k'.
|
||||||
# The format of the file is 'key: 000kB' and an additional
|
# The format of the file is 'key: 000kB' and an additional
|
||||||
# split is used on 'k' to filter out 'kB'.
|
# split is used on 'k' to filter out 'kB'.
|
||||||
while IFS=:k read -r key val _; do
|
while IFS=':k ' read -r key val _; do
|
||||||
case $key in
|
case $key in
|
||||||
MemTotal)
|
MemTotal)
|
||||||
mem_used=$((mem_used + val))
|
mem_used=$((mem_used + val))
|
||||||
@@ -485,7 +520,7 @@ get_memory() {
|
|||||||
mem_full=$((mem_full / 1024))
|
mem_full=$((mem_full / 1024))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Used memory is calculated using the following "formula" (MacOS):
|
# Used memory is calculated using the following "formula":
|
||||||
# (wired + active + occupied) * 4 / 1024
|
# (wired + active + occupied) * 4 / 1024
|
||||||
Darwin*)
|
Darwin*)
|
||||||
mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024))
|
mem_full=$(($(sysctl -n hw.memsize) / 1024 / 1024))
|
||||||
@@ -535,9 +570,9 @@ get_memory() {
|
|||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# Used memory is calculated using the following "formula" (FreeBSD):
|
# Used memory is calculated using the following "formula":
|
||||||
# (inactive_count + free_count + cache_count) * page_size / 1024
|
# mem_full - ((inactive + free + cache) * page_size / 1024)
|
||||||
FreeBSD*)
|
FreeBSD*|DragonFly*)
|
||||||
mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
|
mem_full=$(($(sysctl -n hw.physmem) / 1024 / 1024))
|
||||||
|
|
||||||
# Use 'set --' to store the output of the command in the
|
# Use 'set --' to store the output of the command in the
|
||||||
@@ -559,7 +594,7 @@ get_memory() {
|
|||||||
# $2: vm.stats.vm.v_inactive_count
|
# $2: vm.stats.vm.v_inactive_count
|
||||||
# $3: vm.stats.vm.v_free_count
|
# $3: vm.stats.vm.v_free_count
|
||||||
# $4: vm.stats.vm.v_cache_count
|
# $4: vm.stats.vm.v_cache_count
|
||||||
mem_used=$((($2 + $3 + $4) * $1 / 1024 / 1024))
|
mem_used=$((mem_full - (($2 + $3 + $4) * $1 / 1024 / 1024)))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
NetBSD*)
|
NetBSD*)
|
||||||
@@ -567,7 +602,7 @@ get_memory() {
|
|||||||
|
|
||||||
# NetBSD implements a lot of the Linux '/proc' filesystem,
|
# NetBSD implements a lot of the Linux '/proc' filesystem,
|
||||||
# this uses the same parser as the Linux memory detection.
|
# this uses the same parser as the Linux memory detection.
|
||||||
while IFS=:k read -r key val _; do
|
while IFS=':k ' read -r key val _; do
|
||||||
case $key in
|
case $key in
|
||||||
MemFree)
|
MemFree)
|
||||||
mem_free=$((val / 1024))
|
mem_free=$((val / 1024))
|
||||||
@@ -594,6 +629,35 @@ get_memory() {
|
|||||||
mem_used=$((mem_used / 1024 / 1024))
|
mem_used=$((mem_used / 1024 / 1024))
|
||||||
mem_full=$((mem_full / 1024 / 1024))
|
mem_full=$((mem_full / 1024 / 1024))
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
Minix)
|
||||||
|
# Minix includes the '/proc' filesystem though the format
|
||||||
|
# differs from Linux. The '/proc/meminfo' file is only a
|
||||||
|
# single line with space separated elements and elements
|
||||||
|
# 2 and 3 contain the total and free memory numbers.
|
||||||
|
read -r _ mem_full mem_free _ < /proc/meminfo
|
||||||
|
|
||||||
|
mem_used=$(((mem_full - mem_free) / 1024))
|
||||||
|
mem_full=$(( mem_full / 1024))
|
||||||
|
;;
|
||||||
|
|
||||||
|
SunOS)
|
||||||
|
hw_pagesize=$(pagesize)
|
||||||
|
|
||||||
|
while read -r key val; do
|
||||||
|
case $key in
|
||||||
|
*total) pages_full=$val ;;
|
||||||
|
*free) pages_free=$val ;;
|
||||||
|
esac
|
||||||
|
done <<-EOF
|
||||||
|
$(kstat -p unix:0:system_pages:pagestotal \
|
||||||
|
unix:0:system_pages:pagesfree)
|
||||||
|
EOF
|
||||||
|
|
||||||
|
mem_full=$((pages_full * hw_pagesize / 1024 / 1024))
|
||||||
|
mem_free=$((pages_free * hw_pagesize / 1024 / 1024))
|
||||||
|
mem_used=$((mem_full - mem_free))
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6
|
log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6
|
||||||
@@ -721,6 +785,18 @@ get_ascii() {
|
|||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
[Dd]ragon[Ff]ly*)
|
||||||
|
read_ascii 1 <<-EOF
|
||||||
|
,${c1}_${c7},
|
||||||
|
('-_${c1}|${c7}_-')
|
||||||
|
>--${c1}|${c7}--<
|
||||||
|
(_-'${c1}|${c7}'-_)
|
||||||
|
${c1}|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
|
||||||
[Ee]lementary*)
|
[Ee]lementary*)
|
||||||
read_ascii <<-EOF
|
read_ascii <<-EOF
|
||||||
${c7} _______
|
${c7} _______
|
||||||
@@ -879,6 +955,19 @@ get_ascii() {
|
|||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
[Mm]inix*)
|
||||||
|
read_ascii 4 <<-EOF
|
||||||
|
${c4} ,, ,,
|
||||||
|
;${c7},${c4} ', ,' ${c7},${c4};
|
||||||
|
; ${c7}',${c4} ',,' ${c7},'${c4} ;
|
||||||
|
; ${c7}',${c4} ${c7},'${c4} ;
|
||||||
|
; ${c7};, '' ,;${c4} ;
|
||||||
|
; ${c7};${c4};${c7}',,'${c4};${c7};${c4} ;
|
||||||
|
', ${c7};${c4};; ;;${c7};${c4} ,'
|
||||||
|
'${c7};${c4}' '${c7};${c4}'
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
|
||||||
[Mm][Xx]*)
|
[Mm][Xx]*)
|
||||||
read_ascii <<-EOF
|
read_ascii <<-EOF
|
||||||
${c7} \\\\ /
|
${c7} \\\\ /
|
||||||
@@ -986,6 +1075,27 @@ get_ascii() {
|
|||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
[Ss]un[Oo][Ss])
|
||||||
|
read_ascii 3 <<-EOF
|
||||||
|
${c3} . .; .
|
||||||
|
. :; :: ;: .
|
||||||
|
.;. .. .. .;.
|
||||||
|
.. .. .. ..
|
||||||
|
.;, ,;.
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
|
||||||
|
[Uu]buntu*)
|
||||||
|
read_ascii 3 <<-EOF
|
||||||
|
${c3} _
|
||||||
|
---(_)
|
||||||
|
_/ --- \\
|
||||||
|
(_) | |
|
||||||
|
\\ --- _/
|
||||||
|
---(_)
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
|
||||||
[Vv]oid*)
|
[Vv]oid*)
|
||||||
read_ascii 2 <<-EOF
|
read_ascii 2 <<-EOF
|
||||||
${c2} _______
|
${c2} _______
|
||||||
@@ -1022,8 +1132,12 @@ get_ascii() {
|
|||||||
# information. The 'sed' is used to strip '[3Xm' color codes from
|
# information. The 'sed' is used to strip '[3Xm' color codes from
|
||||||
# the ascii art so they don't affect the width variable.
|
# the ascii art so they don't affect the width variable.
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
: $((ascii_height+=1))
|
ascii_height=$((${ascii_height:-0} + 1))
|
||||||
ascii_width=$((${#line} > ascii_width ? ${#line} : ascii_width))
|
|
||||||
|
# This was a ternary operation but they aren't supported in
|
||||||
|
# Minix's shell.
|
||||||
|
[ "${#line}" -gt "${ascii_width:-0}" ] &&
|
||||||
|
ascii_width=${#line}
|
||||||
|
|
||||||
# Using '<<-EOF' is the only way to loop over a command's
|
# Using '<<-EOF' is the only way to loop over a command's
|
||||||
# output without the use of a pipe ('|').
|
# output without the use of a pipe ('|').
|
||||||
@@ -1034,16 +1148,20 @@ get_ascii() {
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Add a gap between the ascii art and the information.
|
# Add a gap between the ascii art and the information.
|
||||||
: $((ascii_width+=4))
|
ascii_width=$((ascii_width + 4))
|
||||||
|
|
||||||
|
# Minix and DragonFly don't support these!
|
||||||
|
# '[?7l': Disable line-wrapping.
|
||||||
|
# '[?25l': Hide the cursor.
|
||||||
|
[ "$os" != Minix ] && [ "$os" != DragonFly ] &&
|
||||||
|
printf '[?7l[?25l' >&6
|
||||||
|
|
||||||
# Print the ascii art and position the cursor back where we
|
# Print the ascii art and position the cursor back where we
|
||||||
# started prior to printing it.
|
# started prior to printing it.
|
||||||
# '[?7l': Disable line-wrapping.
|
|
||||||
# '[?25l': Hide the cursor.
|
|
||||||
# '[1m': Print the ascii in bold.
|
# '[1m': Print the ascii in bold.
|
||||||
# '[m': Clear bold.
|
# '[m': Clear bold.
|
||||||
# '[%sA': Move the cursor up '$ascii_height' amount of lines.
|
# '[%sA': Move the cursor up '$ascii_height' amount of lines.
|
||||||
printf '[?7l[?25l[1m%s[m[%sA' "$ascii" "$ascii_height" >&6
|
printf '[1m%s[m[%sA' "$ascii" "$ascii_height" >&6
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
@@ -1094,12 +1212,16 @@ main() {
|
|||||||
# "info names" for output alignment. The option names and subtitles
|
# "info names" for output alignment. The option names and subtitles
|
||||||
# match 1:1 so this is thankfully simple.
|
# match 1:1 so this is thankfully simple.
|
||||||
for info; do
|
for info; do
|
||||||
command -v "get_$info" >/dev/null &&
|
command -v "get_$info" >/dev/null || continue
|
||||||
info_length=$((${#info} > info_length ? ${#info} : info_length))
|
|
||||||
|
# This was a ternary operation but they aren't supported in
|
||||||
|
# Minix's shell.
|
||||||
|
[ "${#info}" -gt "${info_length:-0}" ] &&
|
||||||
|
info_length=${#info}
|
||||||
done
|
done
|
||||||
|
|
||||||
# Add an additional space of length to act as a gap.
|
# Add an additional space of length to act as a gap.
|
||||||
: $((info_length+=1))
|
info_length=$((info_length + 1))
|
||||||
|
|
||||||
# Iterate over the above list and run any existing "get_" functions.
|
# Iterate over the above list and run any existing "get_" functions.
|
||||||
for info; do "get_$info"; done
|
for info; do "get_$info"; done
|
||||||
@@ -1107,15 +1229,19 @@ main() {
|
|||||||
|
|
||||||
# Position the cursor below both the ascii art and information lines
|
# Position the cursor below both the ascii art and information lines
|
||||||
# according to the height of both. If the information exceeds the ascii
|
# according to the height of both. If the information exceeds the ascii
|
||||||
# art in height, don't touch the cursor, else move it down N lines.
|
# art in height, don't touch the cursor (0/unset), else move it down
|
||||||
cursor_pos=$((info_height > ascii_height ? 0 : ascii_height - info_height))
|
# N lines.
|
||||||
|
#
|
||||||
|
# This was a ternary operation but they aren't supported in Minix's shell.
|
||||||
|
[ "$info_height" -lt "$ascii_height" ] &&
|
||||||
|
cursor_pos=$((ascii_height - info_height))
|
||||||
|
|
||||||
# Print '$cursor_pos' amount of newlines to correctly position the
|
# Print '$cursor_pos' amount of newlines to correctly position the
|
||||||
# cursor. This used to be a 'printf $(seq X X)' however 'seq' is only
|
# cursor. This used to be a 'printf $(seq X X)' however 'seq' is only
|
||||||
# typically available (by default) on GNU based systems!
|
# typically available (by default) on GNU based systems!
|
||||||
while [ "${i:-0}" -le "$cursor_pos" ]; do
|
while [ "${i:=0}" -le "${cursor_pos:-0}" ]; do
|
||||||
printf '\n'
|
printf '\n'
|
||||||
: $((i+=1))
|
i=$((i + 1))
|
||||||
done >&6
|
done >&6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user