home/bin/info (view raw)
1#!/usr/bin/env bash
2# icyinfo, but better
3
4export BLK="\e[30m"
5export RED="\e[31m"
6export GRN="\e[32m"
7export YLW="\e[33m"
8export BLU="\e[34m"
9export PUR="\e[35m"
10export CYN="\e[36m"
11export BRED="\e[31m"
12export BGRN="\e[32m"
13export BYLW="\e[33m"
14export BBLU="\e[34m"
15export BPUR="\e[35m"
16export BCYN="\e[36m"
17export WHT="\e[37m"
18export RST="\e[0m"
19
20#BAR="████"
21#((LEN = ${#BAR} * 6))
22#COLOR_BARS="$RED$BAR$GRN$BAR$YLW$BAR$BLU$BAR$PUR$BAR$CYN$BAR$RST"
23
24basename() {
25 # Usage: basename "path" ["suffix"]
26 local tmp
27
28 tmp=${1%"${1##*[!/]}"}
29 tmp=${tmp##*/}
30 tmp=${tmp%"${2/"$tmp"}"}
31
32 printf '%s\n' "${tmp:-/}"
33}
34
35prinfo() {
36 # 1 - field
37 # 2 - info
38 # 3 - prev line
39 prev_line="$1$2"
40 export prev_line
41
42
43 printf '\e[%sD\e[B' "${#3}"
44 printf '%b' "${BLU}$1${RST}$2"
45}
46
47user="$USER"
48host="$HOSTNAME"
49kernel="$(uname -r)"
50shell="$(basename "$SHELL")"
51
52# cactus art
53#art="
54#${GRN}
55# o
56#.oo.Oo.
57# O.
58# Ooo'${RST}
59# ${RED}___${RST}${GRN}O${RST}${RED}___
60# \ /
61# \___/${RST}
62#"
63
64# blowfish
65
66printf '\e[?25l'
67printf '\e[2J'
68art="
69${YLW} \.-----./
70 / ^ ^ ^ \ ${RST}
71 (${PUR}o${RST})(${PUR}o${RST})${YLW} ^ ^ |_/|${RST}
72 ${RED}{}${RST} ${YLW}^ ^ > ^| \|
73 \^ ^ ^ ^/
74 /-----\\ ${RST}
75
76"
77
78printf '%b' "$art"
79os="$(uname)"
80pkgs="$(pkg_info | wc -l)"
81
82printf '%b\n' "${CYN}$user${RST}@${CYN}$host${RST}"
83
84prinfo "os" " $os"
85prinfo "kernel" " $kernel" "$prev_line"
86prinfo "pkgs" " $pkgs" "$prev_line"
87prinfo "shell" " $shell" "$prev_line"
88
89
90# Pause
91read -rsn1 _
92clear