可愛いシステム情報表示ツールのpfetch

screenfetchやneofetchと同じようなものですが,shell script 1本で動いてロゴが可愛いです.

$ git clone https://github.com/dylanaraps/pfetch
$ pfetch/pfetch
  _____      matoken@t430s
 /  __ \     os     Debian GNU/Linux bullseye/sid
|  /    |    host   23533KJ ThinkPad T430s
|  \___-     kernel 5.2.0-2-amd64
-_           uptime 8d 3h 7m
  --_        pkgs   5796
             memory 13560M / 15924M

fpetch

現在のバージョンではロゴはこれだけあるよう.

$ grep PF_ASCII: pfetch -A999|grep \*\)
        [Aa]lpine*)
        [Aa]ndroid*)
        [Aa]rch*)
        [Aa]rco*)
        [Aa]rtix*)
        [Cc]ent[Oo][Ss]*)
        [Dd]ebian*)
        [Dd]ragon[Ff]ly*)
        [Ee]lementary*)
        [Ff]edora*)
        [Ff]ree[Bb][Ss][Dd]*)
        [Gg]entoo*)
        [Gg]uix[Ss][Dd]*|[Gg]uix*)
        [Hh]aiku*)
        [Hh]yperbola*)
        [Ll]inux*[Ll]ite*|[Ll]ite*)
        [Ll]inux*)
        [Mm]ac[Oo][Ss]*|[Dd]arwin*)
        [Mm]ageia*)
        [Mm]anjaro*)
        [Mm]inix*)
        [Mm][Xx]*)
        [Nn]et[Bb][Ss][Dd]*)
        [Nn]ix[Oo][Ss]*)
        [Oo]pen[Bb][Ss][Dd]*)
        [Oo]penSUSE*|[Oo]pen*SUSE*|SUSE*|suse*)
        [Pp]arabola*)
        [Pp]op!_[Oo][Ss]*)
        [Pp]ure[Oo][Ss]*)
        [Ss]lackware*)
        [Ss]un[Oo][Ss]|[Ss]olaris*)
        [Uu]buntu*)
        [Vv]oid*)
        *)

環境変数 PF_INFOPF_ASCII で指定したものを表示できるようです.そこでこういうscriptで表示して,

#!/usr/bin/perl
use strict;
use warnings;
use Time::HiRes 'sleep';

my @LIST=('alpine','android','arch','arco','artix','centos','debian','dragonfly','elementary','fedora','freebsd','gentoo','guixsd','haiku','hyperbola','lite','linux','macos','mageia','manjaro','mint','minix','mx','netbsd','nixos','openbsd','suse','parabola','pop!_os','pureos','slackware','sunos','ubuntu','void');

foreach my $dist ( sort @LIST ){
  my $pfetch = `clear`;
  $pfetch .= "$dist\n";
  $pfetch .= `PF_INFO=ascii PF_ASCII=$dist pfetch`;
  print $pfetch;
  sleep(0.5);
}
`PF_INFO=ascii pfetch > /dev/null`;
print "done\n";

asciinemaへのアップロード……に失敗したのでttyrecして,ttygifしてみました.

pfetch logos
$ ttyrec pfetch.tty # 録画開始
$ perl pfetch-logo.pl # logo表示
$ exit  # 録画終了
$ vi pfetch.tty # テキストエディタで頭と最後のゴミ削除
$ resize -s 11 25 # terminalを小さくしておく
$ ttygif -in pfetch.tty # gifに書き出し
$ WINDOWID=`xdotool getactivewindow` ttygif -in pfetch.tty # `cannot get screenshot` と言われる場合

元のロゴはこの ufetch の一部が使われているよう.こちらにはRaspbianもありますね.

ufetch raspbian

余録:ufetchのロゴを楽しむ
$ git clone https://gitlab.com/jschx/ufetch
$ find ./ufetch/ -name "ufetch-*" -executable \! -name "*.png" -print0 | sort -n | xargs -0 -n1 -I{} sh -c "{} 2>/dev/null; sleep 0.5"
環境
$ git log -1
commit 1ff17055b958fb2436bb9810bfba0d97c64390a4 (HEAD -> master, origin/master, origin/HEAD)
Author: Dylan Araps <dylan.araps@gmail.com>
Date:   Tue Oct 1 15:09:43 2019 +0300

    pfetch: fix bug
$ ttygif -v # https://github.com/sugyan/ttygif
0.0.3
$ ls -l `which sh`
lrwxrwxrwx 1 root root 4 Jul 19 03:15 /usr/bin/sh -> dash
$ dpkg-query -W dash perl ttyrec
dash    0.5.10.2-6
perl    5.28.1-6
ttyrec  1.0.8-5+b2
$ lsb_release -dr
Description:    Debian GNU/Linux bullseye/sid
Release:        unstable
$ uname -m
x86_64

Screenfetch的な情報表示コマンドのNeofetch

Screenfetch的な情報表示コマンドのNeofetch

よくデスクトップのキャプチャを取得するときに表示されているScreenfetchコマンドというものがあります.システムの情報とアスキーアートを素敵に表示してくれます. これににたものでNetfetchというものを見かけたので試してみました.こちらは画像も扱えるようです.

導入

以下のページに各種環境への導入方法が書かれています.

Debian sid/stretchにはパッケージがあるようなことが書かれていますが,

Neofetch is in Debian Unstable/Stretch's official repositories.

今はsidのみのようです.

ということでひとまずstretchではこんな感じで導入しました.

$ #-- /etc/apt/sources.list.d/neofetch を作る
$ sudo apt edit-sources neofetch
$ cat /etc/apt/sources.list.d/neofetch.list
deb http://dl.bintray.com/dawidd6/neofetch jessie main
$ #-- 鍵のインポート
$ wget "https://bintray.com/user/downloadSubjectPublicKey?username=bintray" -O Release-neofetch.key
$ gpg Release-neofetch.key
pub   rsa4096 2015-02-17 [SC]
      8756C4F765C9AC3CB6B85D62379CE192D401AB61
uid           Bintray (by JFrog) <bintray@bintray.com>
sub   rsa4096 2015-02-17 [E]
$ sudo apt-key add Release-neofetch.key
$ rm Release-neofetch.key
$ #-- pkg情報更新&pkg導入
$ sudo apt update
$ sudo apt install neofetch

早速実行

$ neofetch --help

    NEOFETCH

    USAGE: neofetch --option "value" --option "value"

    NOTE: There's also a config option for each flag below.

    Info:
    --disable infoname          Allows you to disable an info line from appearing
                                in the output.
                                NOTE: You can supply multiple args. eg.
                                'neofetch --disable cpu gpu disk shell'
                                NOTE: The arguments must all be lowercase.
    --os_arch on/off            Hide/Show OS architecture.
    --speed_type type           Change the type of cpu speed to display.
                                Possible values: current, min, max, bios,
                                scaling_current, scaling_min, scaling_max
                                NOTE: This only support Linux with cpufreq.
    --cpu_shorthand type        Shorten the output of CPU
                                Possible values: name, speed, tiny, on, off
    --cpu_cores type            Whether or not to display the number of CPU cores
                                Takes: logical, physical, off
                                NOTE: 'physical' doesn't work on BSD.
    --cpu_speed on/off          Hide/Show cpu speed.
    --cpu_temp on/off           Hide/Show cpu temperature.
                                NOTE: This only works on Linux and BSD.
                                NOTE: For FreeBSD-based systems, you need to enable coretemp
                                      kernel module.
    --distro_shorthand on/off   Shorten the output of distro (tiny, on, off)
                                NOTE: This option won't work in Windows (Cygwin)
    --kernel_shorthand on/off   Shorten the output of kernel
                                NOTE: This option won't work in BSDs (except PacBSD and PC-BSD)
    --uptime_shorthand on/off   Shorten the output of uptime (tiny, on, off)
    --refresh_rate on/off       Whether to display the refresh rate of each monitor
                                Unsupported on Windows
    --gpu_brand on/off          Enable/Disable GPU brand in output. (AMD/NVIDIA/Intel)
    --gtk_shorthand on/off      Shorten output of gtk theme/icons
    --gtk2 on/off               Enable/Disable gtk2 theme/icons output
    --gtk3 on/off               Enable/Disable gtk3 theme/icons output
    --shell_path on/off         Enable/Disable showing $SHELL path
    --shell_version on/off      Enable/Disable showing $SHELL version
    --ip_host url               Url to query for public IP
    --song_shorthand on/off     Print the Artist/Title on seperate lines
    --birthday_shorthand on/off Shorten the output of birthday
    --birthday_time on/off      Enable/Disable showing the time in birthday output
    --birthday_format format    Format the birthday output. (Uses 'date' cmd format)

    Text Formatting:
    --colors x x x x x x        Changes the text colors in this order:
                                title, @, underline, subtitle, colon, info
    --underline on/off          Enable/Disable the underline.
    --underline_char char       Character to use when underlining title
    --bold on/off               Enable/Disable bold text

    Color Blocks:
    --color_blocks on/off       Enable/Disable the color blocks
    --block_width num           Width of color blocks in spaces
    --block_height num          Height of color blocks in lines
    --block_range start end     Range of colors to print as blocks

    Bars:
    --bar_char 'elapsed char' 'total char'
                                Characters to use when drawing bars.
    --bar_border on/off         Whether or not to surround the bar with '[]'
    --bar_length num            Length in spaces to make the bars.
    --bar_colors num num        Colors to make the bar.
                                Set in this order: elapsed, total
    --cpu_display mode          Bar mode.
                                Takes: bar, infobar, barinfo, off
    --memory_display mode       Bar mode.
                                Takes: bar, infobar, barinfo, off
    --battery_display mode      Bar mode.
                                Takes: bar, infobar, barinfo, off
    --disk_display mode         Bar mode.
                                Takes: bar, infobar, barinfo, off

    Image:
    --image type                Image source. Where and what image we display.
                                Possible values: wall, ascii,
                                /path/to/img, /path/to/dir/, off
    --size 00px | --size 00%    How to size the image.
                                Possible values: auto, 00px, 00%, none
    --crop_mode mode            Which crop mode to use
                                Takes the values: normal, fit, fill
    --crop_offset value         Change the crop offset for normal mode.
                                Possible values: northwest, north, northeast,
                                west, center, east, southwest, south, southeast

    --xoffset px                How close the image will be to the left edge of the
                                window. This only works with w3m.
    --yoffset px                How close the image will be to the top edge of the
                                window. This only works with w3m.
    --bg_color color            Background color to display behind transparent image.
                                This only works with w3m.
    --gap num                   Gap between image and text.
                                NOTE: --gap can take a negative value which will
                                move the text closer to the left side.
    --clean                     Delete cached files and thumbnails.

    Ascii:
    --ascii value               Where to get the ascii from, Possible values:
                                distro, /path/to/ascii
    --ascii_colors x x x x x x  Colors to print the ascii art
    --ascii_distro distro       Which Distro's ascii art to print
                                NOTE: Arch and Ubuntu have 'old' logo varients.
                                NOTE: Use 'arch_old' or 'ubuntu_old' to use the old logos.
                                NOTE: Ubuntu has flavor varients.
                                NOTE: Change this to 'Lubuntu', 'Xubuntu', 'Ubuntu-GNOME'
                                or 'Ubuntu-Budgie' to use the flavors.
    --ascii_logo_size           Size of ascii logo.
                                Supported distros: Arch, Gentoo, Crux, OpenBSD.
    --ascii_bold on/off         Whether or not to bold the ascii logo.
    --logo | -L                 Hide the info text and only show the ascii logo.

    Screenshot:
    --scrot | -s /path/to/img   Take a screenshot, if path is left empty the screen-
                                shot function will use $scrot_dir and $scrot_name.
    --upload | -su /pth/t/img   Same as --scrot but uploads the scrot to a website.
    --image_host                Website to upload scrots to. Takes: imgur, teknik
    --scrot_cmd cmd             Screenshot program to launch

    Other:
    --config /path/to/config    Specify a path to a custom config file
    --config none               Launch the script without a config file
    --help                      Print this text and exit
    --version                   Show neofetch version
    -v                          Display error messages.
    -vv                         Display a verbose log for error reporting.

オプション結構多いです. とりあえず素で実行.

20161207_05:12:12-5188

情報もScreenfetchより増えています.

20161207_05:12:20-9093

次は画像を指定してみます.画像サイズが大きかったので25%に縮小もしています. 楽しい :)

20161207_05:12:35-3963

20161207_06:12:30-16979

画像の表示については環境によってうまく行く行かないがあるようです.うまく表示されない場合は以下のWikiを参照すると良さそうです.