8 Commits
term ... 0.1

Author SHA1 Message Date
Dylan Araps
1b37bf9dd2 docs: update 2019-09-28 10:32:41 +03:00
Dylan Araps
eb9c8a3cfe pfetch: WSL support 2019-09-28 10:30:59 +03:00
Dylan Araps
59340ff4ce pkgs: fix extra count 2019-09-28 07:25:20 +03:00
Dylan Araps
68d2422a1b os: fixed lsb_release, closes #14 2019-09-28 07:01:50 +03:00
Dylan Araps
55b78b9e58 docs: update 2019-09-27 22:45:16 +03:00
Dylan Araps
b7292e0cbc docs: update 2019-09-27 22:03:34 +03:00
Dylan Araps
ba03cb3cf4 pfetch: add get_palette 2019-09-27 21:49:44 +03:00
Dylan Araps
d91cd1c0bf docs: update 2019-09-27 21:04:00 +03:00
2 changed files with 58 additions and 19 deletions

View File

@@ -32,9 +32,10 @@ _/\ __)/_) pkgs 130
- [ ] Add optional and additional information detection. - [ ] Add optional and additional information detection.
- [ ] CPU - [ ] CPU
- [ ] Terminal Emulator - [ ] Terminal Emulator ([#12](https://github.com/dylanaraps/pfetch/pull/12))
- The way I implement this in `neofetch` is interesting. - The way I implement this in `neofetch` is interesting.
- [ ] Terminal colors - [x] Terminal colors ([commit](https://github.com/dylanaraps/pfetch/commit/ba03cb3cf4dfbc767abce6acd53c07ab5568e23d))
- [ ] 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)) - [ ] Solaris ([#5](https://github.com/dylanaraps/pfetch/issues/5))
@@ -46,7 +47,7 @@ _/\ __)/_) pkgs 130
- [ ] CYGWIN - [ ] CYGWIN
- [ ] MSYS - [ ] MSYS
- [ ] MINGW - [ ] MINGW
- [ ] WSL (*this is fairly simple*) - [x] WSL (*this is fairly simple*)
## Configuration ## Configuration
@@ -58,7 +59,7 @@ _/\ __)/_) pkgs 130
# Default: first example below # Default: first example below
# Valid: space separated string # Valid: space separated string
# #
# OFF by default: shell # OFF by default: shell palette
PF_INFO="ascii title distro host kernel uptime pkgs memory" PF_INFO="ascii title distro host kernel uptime pkgs memory"
# Example: Only ASCII. # Example: Only ASCII.

68
pfetch
View File

@@ -154,6 +154,12 @@ 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 # Disable warning about shellcheck not being able
# to read '/etc/os-release'. This is fine. # to read '/etc/os-release'. This is fine.
@@ -165,6 +171,19 @@ get_os() {
# 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
# WSL (Windows subsystem for Linux) and append a string
# accordingly.
#
# If the kernel version string ends in "-Microsoft",
# we're very likely running under Windows 10 in WSL.
#
# This also acts as a means of allowing the user to
# fake this by changing their kernel version to end in
# "Microsoft".
[ "${kernel%%*-Microsoft}" ] ||
distro="$distro on Windows 10"
;; ;;
Darwin*) Darwin*)
@@ -356,6 +375,10 @@ get_uptime() {
} }
get_pkgs() { get_pkgs() {
# This is just a simple wrapper around 'command -v' to avoid
# spamming '>/dev/null' throughout this function.
has() { command -v "$1" >/dev/null; }
# This works by first checking for which package managers are # This works by first checking for which package managers are
# installed and finally by printing each package manager's # installed and finally by printing each package manager's
# package list with each package one per line. # package list with each package one per line.
@@ -376,27 +399,27 @@ get_pkgs() {
case $os in case $os in
Linux*) Linux*)
# Commands which print packages one per line. # Commands which print packages one per line.
command -v kiss && kiss l has kiss && kiss l
command -v bonsai && bonsai list has bonsai && bonsai list
command -v pacman-key && pacman -Qq has pacman-key && pacman -Qq
command -v dpkg && dpkg-query -f '.\n' -W has dpkg && dpkg-query -f '.\n' -W
command -v rpm && rpm -qa has rpm && rpm -qa
command -v xbps-query && xbps-query -l has xbps-query && xbps-query -l
command -v apk && apk info has apk && apk info
# Directories containing packages. # Directories containing packages.
command -v brew && printf '%s\n' "$(brew --cellar)/"* has brew && printf '%s\n' "$(brew --cellar)/"*
command -v emerge && printf '%s\n' /var/db/pkg/*/*/ has emerge && printf '%s\n' /var/db/pkg/*/*/
command -v pkgtool && printf '%s\n' /var/log/packages/* has pkgtool && printf '%s\n' /var/log/packages/*
# GUIX requires two commands. # GUIX requires two commands.
command -v guix && { has guix && {
guix package -p /run/current-system/profile -I guix package -p /run/current-system/profile -I
guix package -I guix package -I
} }
# NIX requires two commands. # NIX requires two commands.
command -v nix-store && { has nix-store && {
nix-store -q --requisites /run/current-system/sw nix-store -q --requisites /run/current-system/sw
nix-store -q --requisites ~.nix-profile nix-store -q --requisites ~.nix-profile
} }
@@ -404,11 +427,11 @@ get_pkgs() {
Darwin*) Darwin*)
# Commands which print packages one per line. # Commands which print packages one per line.
command -v pkgin && pkgin list has pkgin && pkgin list
command -v port && port installed has port && port installed
# Directories containing packages. # Directories containing packages.
command -v brew && printf '%s\n' /usr/local/Cellar/* has brew && printf '%s\n' /usr/local/Cellar/*
;; ;;
FreeBSD*) FreeBSD*)
@@ -576,6 +599,21 @@ get_memory() {
log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6 log memory "${mem_used:-?}M / ${mem_full:-?}M" >&6
} }
get_palette() {
# Print the first 8 terminal colors. This uses the existing
# sequences to change text color with a sequence prepended
# to reverse the foreground and background colors.
#
# This allows us to save hardcoding a second set of sequences
# for background colors.
palette=" $c1 $c2 $c3 $c4 $c5 $c6 $c7 "
# Print the palette with a newline before and after.
# The '\033[%sC' moves the text to the right, the
# length of the ascii art.
printf '\n[%sC%s\n' "${ascii_width-1}" "$palette" >&6
}
get_ascii() { get_ascii() {
# This is a simple function to read the contents of # This is a simple function to read the contents of
# an ascii file from 'stdin'. It allows for the use # an ascii file from 'stdin'. It allows for the use