Add env var to change what info is displayed

This commit is contained in:
GaugeK committed 2020-08-19 05:21:48 +10:00
1 parent acec5ad4c5
commit a0ee667546
2 files changed
+36 -29

No files matched your search

+7 -8
View File
@@ -1,21 +1,20 @@
<h2 align="center">fet.sh</h1>
<div align="center"> <div align="center">
<h1>fet.sh</h1>
fetch written in POSIX shell with no external commands fetch written in POSIX shell with no external commands
<br> <br>
<img src="screenshot.png" width="250px"> <img src="screenshot.png" width="250px">
</div> </div>
### Installing ### Installing
**Arch:** [fet.sh-git](https://aur.archlinux.org/packages/fet.sh-git/) (AUR) **Arch:** [fet.sh-git](https://aur.archlinux.org/packages/fet.sh-git/) (AUR)
**Other Distros:** copy `fet.sh` to somewhere in $PATH **Other Distros:** copy `fet.sh` to somewhere in $PATH
### Customization ### Customization
`fet.sh` can be configured using environment variables, for example: `fet.sh` can be configured using environment variables, for example:
```sh ```
$ separator=" > " fet.sh $ info='os wm sh' fet.sh
``` ```
Supported options are: Supported options are:
- `accent` - `accent` (0-7)
- `info`
- `separator` - `separator`
+29 -21
View File
@@ -99,29 +99,37 @@ read -r model < /sys/devices/virtual/dmi/id/product_name
[ -d /var/db/pkg ] && set -- /var/db/pkg/*/* [ -d /var/db/pkg ] && set -- /var/db/pkg/*/*
[ $# -gt 0 ] && pkgs=$# [ $# -gt 0 ] && pkgs=$#
print() { col() {
[ "$2" ] && printf '\033[9%sm%6s\033[0m%b%s\n' "${accent:-4}" "$1" "${separator:- ~ }" "$2" printf ' '
for i in 1 2 3 4 5 6; do
printf '\033[9%sm▅▅' "$i"
done
printf '\033[0m\n'
} }
print() {
[ "$2" ] && printf '\033[9%sm%6s\033[0m%b%s\n' \
"${accent:-4}" "$1" "${separator:- ~ }" "$2"
}
read -r host < /proc/sys/kernel/hostname
echo echo
read -r host < /proc/sys/kernel/hostname for i in ${info:-user os sh wm up gtk cpu mem host kern pkgs term col}; do
printf '%7s@%s\n' "$USER" "$host" case $i in
os) print os "$ID";;
print os "$ID" sh) print sh "${SHELL##*/}";;
print sh "${SHELL##*/}" wm) print wm "$wm";;
print wm "$wm" up) print up "$up";;
print up "$up" gtk) print gtk "${gtk# }";;
print gtk "${gtk# }" gpu) print cpu "$vendor $cpu";;
print cpu "$vendor $cpu" mem) print mem "${mem}MB";;
print mem "${mem}MB" host) print host "$model";;
print host "$model" kern) print kern "$kernel";;
print kern "$kernel" pkgs) print pkgs "$pkgs";;
print pkgs "$pkgs" term) print term "$term";;
print term "$term" user) printf '%7s@%s\n' "$USER" "$host";;
col) col;;
printf ' ' esac
for i in 1 2 3 4 5 6; do
printf '\033[9%sm▅▅' "$i"
done done
printf '\033[0m\n\n' echo