mirror of
https://github.com/dylanaraps/pfetch.git
synced 2026-01-02 16:02:12 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ca67a75c4 |
92
README.md
92
README.md
@@ -1,42 +1,80 @@
|
|||||||
<p align="center"><img src="https://user-images.githubusercontent.com/6799467/65944518-68834d80-e421-11e9-9b14-6ca26a16108a.png" width="350px"></p>
|
# pfetch
|
||||||
<h1 align="center">pfetch</h1>
|
|
||||||
<p align="center">A pretty system information tool written in POSIX sh</p><br>
|
|
||||||
|
|
||||||
<img src="https://user-images.githubusercontent.com/6799467/65945384-5bfff480-e423-11e9-863e-4e7cf16eb648.png" width="40%" align="right">
|
A pretty system information tool written in POSIX `sh`.
|
||||||
|
|
||||||
The goal of this project is to implement a simple system
|
The goal of this project is to implement a simple system information tool in POSIX `sh` using features built into the language itself (*where possible*).
|
||||||
information tool in POSIX `sh` using features built into
|
|
||||||
the language itself (*where possible*).
|
|
||||||
|
|
||||||
The source code is highly documented and I hope it will
|
The source code is highly documented and I hope it will act as a learning resource for POSIX `sh` and simple information detection across various different operating systems.
|
||||||
act as a learning resource for POSIX `sh` and simple
|
|
||||||
information detection across various different operating
|
|
||||||
systems.
|
|
||||||
|
|
||||||
If anything in the source code is unclear or is lacking
|
If anything in the source code is unclear or is lacking in its explanation, open an issue. Sometimes you get too close to something and you fail to see the "bigger picture"!
|
||||||
in its explanation, open an issue. Sometimes you get too
|
|
||||||
close to something and you fail to see the "bigger
|
|
||||||
picture"!
|
|
||||||
|
|
||||||
<br>
|
```sh
|
||||||
<br>
|
➜ pfetch
|
||||||
<br>
|
___ goldie@KISS
|
||||||
<br>
|
(.· | os KISS Linux
|
||||||
|
(<> | host Lenovo YOGA 900-13ISK
|
||||||
|
/ __ \ kernel 5.3.1-coffee
|
||||||
|
( / \ /| uptime 6h 20m
|
||||||
|
_/\ __)/_) pkgs 130
|
||||||
|
\/-____\/ memory 1721M / 7942M
|
||||||
|
```
|
||||||
|
|
||||||
## OS support
|
## OS support
|
||||||
|
|
||||||
- **Linux**
|
|
||||||
- Alpine Linux, Arch Linux, Arco Linux, Artix Linux, 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 and Void Linux.
|
|
||||||
- All other distributions are supported with a generic penguin logo.
|
|
||||||
- **Android**
|
|
||||||
- **BSD**
|
|
||||||
- DragonflyBSD, FreeBSD, NetBSD and OpenBSD.
|
|
||||||
- **Windows**
|
|
||||||
- Windows subsystem for Linux.
|
|
||||||
- **Haiku**
|
- **Haiku**
|
||||||
- **MacOS**
|
- **MacOS**
|
||||||
- **Minix**
|
- **Minix**
|
||||||
- **Solaris**
|
- **Solaris**
|
||||||
|
- **BSD**
|
||||||
|
- DragonflyBSD
|
||||||
|
- FreeBSD
|
||||||
|
- NetBSD
|
||||||
|
- OpenBSD
|
||||||
|
- **Windows**
|
||||||
|
- Windows subsystem for Linux.
|
||||||
|
- **Linux**
|
||||||
|
- Alpine Linux
|
||||||
|
- Arch Linux
|
||||||
|
- Arco Linux
|
||||||
|
- Artix Linux
|
||||||
|
- 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
|
||||||
|
- Other distributions are supported with a generic penguin logo.
|
||||||
|
|
||||||
|
## TODO
|
||||||
|
|
||||||
|
- [ ] Add optional and additional information detection.
|
||||||
|
- [ ] Terminal Emulator ([#12](https://github.com/dylanaraps/pfetch/pull/12))
|
||||||
|
- The way I implement this in `neofetch` is interesting.
|
||||||
|
- [ ] Expand operating system support.
|
||||||
|
- [ ] Android
|
||||||
|
- [ ] iOS
|
||||||
|
- [ ] AIX ([#7](https://github.com/dylanaraps/pfetch/issues/7))
|
||||||
|
- [ ] IRIX ([#8](https://github.com/dylanaraps/pfetch/issues/8))
|
||||||
|
- [ ] FreeMiNT ([#9](https://github.com/dylanaraps/pfetch/issues/9))
|
||||||
|
- [ ] Windows ([#10](https://github.com/dylanaraps/pfetch/issues/10))
|
||||||
|
- [ ] CYGWIN
|
||||||
|
- [ ] MSYS
|
||||||
|
- [ ] MINGW
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
|
|||||||
104
pfetch
104
pfetch
@@ -129,7 +129,7 @@ get_os() {
|
|||||||
|
|
||||||
case $os in
|
case $os in
|
||||||
Linux*)
|
Linux*)
|
||||||
# Some Linux distributions (which are based on others)
|
# Some Linux disttributions (which are based on others)
|
||||||
# fail to identify as they **do not** change the upstream
|
# fail to identify as they **do not** change the upstream
|
||||||
# distributions identification packages or files.
|
# distributions identification packages or files.
|
||||||
#
|
#
|
||||||
@@ -154,12 +154,6 @@ get_os() {
|
|||||||
if command -v lsb_release; then
|
if command -v lsb_release; then
|
||||||
distro=$(lsb_release -sd)
|
distro=$(lsb_release -sd)
|
||||||
|
|
||||||
# Android detection works by checking for the existence of
|
|
||||||
# the follow two directories. I don't think there's a simpler
|
|
||||||
# method than this.
|
|
||||||
elif [ -d /system/app ] && [ -d /system/priv-app ]; then
|
|
||||||
distro="Android $(getprop ro.build.version.release)"
|
|
||||||
|
|
||||||
else
|
else
|
||||||
# This used to be a simple '. /etc/os-release' but I believe
|
# This used to be a simple '. /etc/os-release' but I believe
|
||||||
# this is insecure as we blindly executed whatever was in the
|
# this is insecure as we blindly executed whatever was in the
|
||||||
@@ -267,6 +261,19 @@ get_os() {
|
|||||||
IFS='(' read -r distro _ < /etc/release
|
IFS='(' read -r distro _ < /etc/release
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
CYGWIN*|MSYS*|MINGW*)
|
||||||
|
# Grab everything after the first instance of
|
||||||
|
# white-space in the command output of 'wmic'.
|
||||||
|
#
|
||||||
|
# The format of 'wmic' is as follows:
|
||||||
|
# Caption=Microsoft Windows 7 Enterprise
|
||||||
|
#
|
||||||
|
# This extracts: ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
read -r _ distro <<-EOF
|
||||||
|
$(wmic os get Caption /value)
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
# Catch all to ensure '$distro' is never blank.
|
# Catch all to ensure '$distro' is never blank.
|
||||||
# This also handles the BSDs.
|
# This also handles the BSDs.
|
||||||
@@ -313,6 +320,21 @@ get_host() {
|
|||||||
*BSD*)
|
*BSD*)
|
||||||
host=$(sysctl -n hw.vendor hw.product)
|
host=$(sysctl -n hw.vendor hw.product)
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
CYGWIN*|MSYS*|MINGW*)
|
||||||
|
# Grab everything after the first instance of '=' in each
|
||||||
|
# line of the command output of 'wmic'. Append the output
|
||||||
|
# of each line to the '$host' variable.
|
||||||
|
#
|
||||||
|
# The format of 'wmic' is as follows:
|
||||||
|
# Manufacturer=VMware, Inc.
|
||||||
|
# Model=VMware Virtual Platform
|
||||||
|
while IFS='=' read -r _ val; do
|
||||||
|
host="${host}${val:+ $val}"
|
||||||
|
done <<-EOF
|
||||||
|
$(wmic computersystem get manufacturer,model /value)
|
||||||
|
EOF
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Turn the host string into an argument list so we can iterate
|
# Turn the host string into an argument list so we can iterate
|
||||||
@@ -345,7 +367,7 @@ get_host() {
|
|||||||
case $word in
|
case $word in
|
||||||
To | [Bb]e | [Ff]illed | by | O.E.M. | OEM |\
|
To | [Bb]e | [Ff]illed | by | O.E.M. | OEM |\
|
||||||
Not | Applicable | Specified | System | Product | Name |\
|
Not | Applicable | Specified | System | Product | Name |\
|
||||||
Version | Undefined | Default | string | INVALID | <20> | os )
|
Version | Undefined | Default | string | INVALID | <20> )
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -362,7 +384,7 @@ 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*|Minix*)
|
Linux*|Minix*|CYGWIN*|MSYS*|MINGW*)
|
||||||
IFS=. read -r s _ < /proc/uptime
|
IFS=. read -r s _ < /proc/uptime
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -461,24 +483,10 @@ get_pkgs() {
|
|||||||
Darwin*)
|
Darwin*)
|
||||||
# Commands which print packages one per line.
|
# Commands which print packages one per line.
|
||||||
has pkgin && pkgin list
|
has pkgin && pkgin list
|
||||||
|
has port && port installed
|
||||||
|
|
||||||
# Directories containing packages.
|
# Directories containing packages.
|
||||||
has brew && printf '%s\n' /usr/local/Cellar/*
|
has brew && printf '%s\n' /usr/local/Cellar/*
|
||||||
|
|
||||||
# 'port' prints a single line of output to 'stdout'
|
|
||||||
# when no packages are installed and exits with
|
|
||||||
# success causing a false-positive of 1 package
|
|
||||||
# installed.
|
|
||||||
#
|
|
||||||
# 'port' should really exit with a non-zero code
|
|
||||||
# in this case to allow scripts to cleanly handle
|
|
||||||
# this behavior.
|
|
||||||
has port && {
|
|
||||||
pkg_list=$(port installed)
|
|
||||||
|
|
||||||
[ "$pkg_list" = "No ports are installed." ] ||
|
|
||||||
printf '%s\n' "$pkg_list"
|
|
||||||
}
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
FreeBSD*|DragonFly*)
|
FreeBSD*|DragonFly*)
|
||||||
@@ -505,6 +513,14 @@ get_pkgs() {
|
|||||||
has pkginfo && pkginfo -i
|
has pkginfo && pkginfo -i
|
||||||
has pkg && pkg list
|
has pkg && pkg list
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
CYGWIN*)
|
||||||
|
cygcheck -cd
|
||||||
|
;;
|
||||||
|
|
||||||
|
MSYS*)
|
||||||
|
pacman -Qq
|
||||||
|
;;
|
||||||
esac | wc -l
|
esac | wc -l
|
||||||
`
|
`
|
||||||
|
|
||||||
@@ -516,7 +532,7 @@ get_memory() {
|
|||||||
# Used memory is calculated using the following "formula":
|
# 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*|CYGWIN*|MSYS*|MINGW*)
|
||||||
# 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'.
|
||||||
@@ -551,7 +567,7 @@ get_memory() {
|
|||||||
# split is used on '.' to filter it out.
|
# split is used on '.' to filter it out.
|
||||||
while IFS=:. read -r key val; do
|
while IFS=:. read -r key val; do
|
||||||
case $key in
|
case $key in
|
||||||
*' wired'*|*' active'*|*' occupied'*)
|
*wired*|*active*|*occupied*)
|
||||||
mem_used=$((mem_used + ${val:-0}))
|
mem_used=$((mem_used + ${val:-0}))
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -771,17 +787,8 @@ get_wm() {
|
|||||||
# To extract the name, everything before '_NET_WM_NAME = \"'
|
# To extract the name, everything before '_NET_WM_NAME = \"'
|
||||||
# is removed and everything after the next '"' is removed.
|
# is removed and everything after the next '"' is removed.
|
||||||
wm=$(xprop -id "$id" -notype -len 25 -f _NET_WM_NAME 8t)
|
wm=$(xprop -id "$id" -notype -len 25 -f _NET_WM_NAME 8t)
|
||||||
|
|
||||||
# Handle cases of a window manager _not_ populating the
|
|
||||||
# '_NET_WM_NAME' atom. Display nothing in this case.
|
|
||||||
case $wm in
|
|
||||||
*'_NET_WM_NAME = '*)
|
|
||||||
wm=${wm##*_NET_WM_NAME = \"}
|
wm=${wm##*_NET_WM_NAME = \"}
|
||||||
wm=${wm%%\"*}
|
wm=${wm%%\"*}
|
||||||
;;
|
|
||||||
|
|
||||||
*) wm= ;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@@ -888,12 +895,12 @@ get_ascii() {
|
|||||||
[Aa]rch*)
|
[Aa]rch*)
|
||||||
read_ascii 4 <<-EOF
|
read_ascii 4 <<-EOF
|
||||||
${c6} /\\
|
${c6} /\\
|
||||||
/ \\
|
/^^\\
|
||||||
/\\ \\
|
/\\ \\
|
||||||
${c4} / \\
|
/${c7} __ \\
|
||||||
/ ,, \\
|
/ ( ) \\
|
||||||
/ | | -\\
|
/ __| |__\\\\
|
||||||
/_-'' ''-_\\
|
/// \\\\\\
|
||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -982,12 +989,13 @@ get_ascii() {
|
|||||||
|
|
||||||
[Ff]ree[Bb][Ss][Dd]*)
|
[Ff]ree[Bb][Ss][Dd]*)
|
||||||
read_ascii 1 <<-EOF
|
read_ascii 1 <<-EOF
|
||||||
${c1}/\\,-'''''-,/\\
|
${c1} /\\ _____ /\\
|
||||||
\\_) (_/
|
\\_) (_/
|
||||||
|
/ \\
|
||||||
| |
|
| |
|
||||||
| |
|
| |
|
||||||
; ;
|
\ /
|
||||||
'-_____-'
|
--_____--
|
||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -1003,7 +1011,7 @@ get_ascii() {
|
|||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
[Gg]uix[Ss][Dd]*|[Gg]uix*)
|
[Gg]uix[Ss][Dd]*|guix*)
|
||||||
read_ascii 3 <<-EOF
|
read_ascii 3 <<-EOF
|
||||||
${c3}|.__ __.|
|
${c3}|.__ __.|
|
||||||
|__ \\ / __|
|
|__ \\ / __|
|
||||||
@@ -1040,7 +1048,7 @@ get_ascii() {
|
|||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
[Ll]inux*[Ll]ite*|[Ll]ite*)
|
[Ll]inux*[Ll]ite*)
|
||||||
read_ascii 3 <<-EOF
|
read_ascii 3 <<-EOF
|
||||||
${c3} /\\
|
${c3} /\\
|
||||||
/ \\
|
/ \\
|
||||||
@@ -1174,7 +1182,7 @@ get_ascii() {
|
|||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
[Oo]penSUSE*|[Oo]pen*SUSE*|SUSE*|suse*)
|
openSUSE*|open*SUSE*|SUSE*|suse*)
|
||||||
read_ascii 2 <<-EOF
|
read_ascii 2 <<-EOF
|
||||||
${c2} _______
|
${c2} _______
|
||||||
__| __ \\
|
__| __ \\
|
||||||
@@ -1233,7 +1241,7 @@ get_ascii() {
|
|||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
[Ss]un[Oo][Ss]|[Ss]olaris*)
|
[Ss]un[Oo][Ss])
|
||||||
read_ascii 3 <<-EOF
|
read_ascii 3 <<-EOF
|
||||||
${c3} . .; .
|
${c3} . .; .
|
||||||
. :; :: ;: .
|
. :; :: ;: .
|
||||||
@@ -1400,7 +1408,7 @@ main() {
|
|||||||
# N lines.
|
# N lines.
|
||||||
#
|
#
|
||||||
# This was a ternary operation but they aren't supported in Minix's shell.
|
# This was a ternary operation but they aren't supported in Minix's shell.
|
||||||
[ "${info_height:-0}" -lt "${ascii_height:-0}" ] &&
|
[ "$info_height" -lt "$ascii_height" ] &&
|
||||||
cursor_pos=$((ascii_height - info_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
|
||||||
|
|||||||
Reference in New Issue
Block a user