# vim:ft=bash # See this wiki page for more info: # https://github.com/dylanaraps/neofetch/wiki/Customizing-Info # Prepare ------------------------------------------------------------------------------------------ pokemon=${1:-$(shuf -i 1-905 -n 1)} data_pokemon=$(curl -fsLS "https://pokeapi.co/api/v2/pokemon/${pokemon}") data_species=$(curl -fsLS "$(echo "${data_pokemon}" | jq --raw-output .species.url)") id=$(echo "${data_species}" | jq --raw-output .id) name=$(echo "${data_species}" | jq --raw-output '.names | .[] | select(.language.name == "en").name') category=$(echo "${data_species}" | jq --raw-output '.genera | .[] | select(.language.name == "en").genus') title="▐ No.$(printf '%03d' "${id}") ▌ ${name} - ${category}" for type in $(echo "${data_pokemon}" | jq --raw-output '.types | .[].type.name' | tr '[:lower:]' '[:upper:]'); do case "${type}" in NORMAL) color=7 ;; FIRE) color=9 ;; WATER) color=12 ;; ELECTRIC) color=11 ;; GRASS) color=10 ;; ICE) color=14 ;; FIGHTING) color=1 ;; POISON) color=5 ;; GROUND) color=11 ;; FLYING) color=6 ;; PSYCHIC) color=13 ;; BUG) color=2 ;; ROCK) color=3 ;; GHOST) color=4 ;; DRAGON) color=4 ;; DARK) color=3 ;; STEEL) color=8 ;; FAIRY) color=13 ;; esac types="${types} [7;38;5;${color}m ${type}  " done height=$(awk "BEGIN{ print $(echo "${data_pokemon}" | jq --raw-output .height) / 10 }") weight=$(awk "BEGIN{ print $(echo "${data_pokemon}" | jq --raw-output .weight) / 10 }") status=$(gum style --align center --width 44 "${types}" "Height: ${height}m Weight: ${weight}kg") info=$(gum join --vertical "${title}" '' "${status}") pokemon_path=$(echo "${data_pokemon}" | jq --raw-output .name) art=$(gum style "$(curl -fsLS "https://gitlab.com/phoneybadger/pokemon-colorscripts/-/raw/main/colorscripts/small/regular/${pokemon_path}" | sed -e 's/$//g')") terminal_size=$(stty size) terminal_height=${terminal_size% *} terminal_width=${terminal_size#* } prompt_height=${PROMPT_HEIGHT:-1} print_test() { no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g') [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1 [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1 gum style --align center --width="${terminal_width}" "${1}" '' printf '%b' "\033[A" exit 0 } # Display ------------------------------------------------------------------------------------------ prin() { # If $2 doesn't exist we format $1 as info. if [[ "$(trim "$1")" && "$2" ]]; then [[ "$json" ]] && { printf ' %s\n' "\"${1}\" \"${2}\","; return; } string="${1}${2:+: $2}" else string="${2:-$1}" local subtitle_color="$info_color" fi # disabling trim function so can make alained #string="$(trim "${string//$'\e[0m'}")" length="$(strip_sequences "$string")" length="${#length}" # Format the output. string="${string/:/${reset}${colon_color}${separator:=:}${info_color}}" string="${subtitle_color}${bold}${string}" # Print the info. printf '%b\n' "${text_padding:+\e[${text_padding}C}${zws}${string//\\n}${reset} " # Calculate info height. ((++info_height)) # Log that prin was used. prin=1 } get_packages() { # to adjust the number of pkgs per pkg manager pkgs_h=0 # has: Check if package manager installed. # dir: Count files or dirs in a glob. # pac: If packages > 0, log package manager name. # tot: Count lines in command output. has() { type -p "$1" >/dev/null && manager=$1; } # globbing is intentional here # shellcheck disable=SC2206 dir() { pkgs=($@); ((packages+=${#pkgs[@]})); pac "$((${#pkgs[@]}-pkgs_h))"; } pac() { (($1 > 0)) && { managers+=("${manager} $1"); manager_string+="${manager}, "; }; } tot() { IFS=$'\n' read -d "" -ra pkgs <<< "$("$@")"; ((packages+=${#pkgs[@]})); pac "$((${#pkgs[@]}-pkgs_h))"; } case $os in Linux|BSD|"iPhone OS"|Solaris) # Package Manager Programs. has kiss && tot kiss l has cpt-list && tot cpt-list has pacman-key && tot pacman -Qq --color never has dpkg && tot dpkg-query -f '.\n' -W has xbps-query && tot xbps-query -l has apk && tot apk info has opkg && tot opkg list-installed has pacman-g2 && tot pacman-g2 -Q has lvu && tot lvu installed has tce-status && tot tce-status -i has pkg_info && tot pkg_info has pkgin && tot pkgin list has tazpkg && pkgs_h=6 tot tazpkg list && ((packages-=6)) has sorcery && tot gaze installed has alps && tot alps showinstalled has butch && tot butch list has swupd && tot swupd bundle-list --quiet has pisi && tot pisi li has pacstall && tot pacstall -L # Using the dnf package cache is much faster than rpm. if has dnf && type -p sqlite3 >/dev/null && [[ -f /var/cache/dnf/packages.db ]]; then pac "$(sqlite3 /var/cache/dnf/packages.db "SELECT count(pkg) FROM installed")" else has rpm && tot rpm -qa fi # 'mine' conflicts with minesweeper games. [[ -f /etc/SDE-VERSION ]] && has mine && tot mine -q # Counting files/dirs. # Variables need to be unquoted here. Only Bedrock Linux is affected. # $br_prefix is fixed and won't change based on user input so this is safe either way. # shellcheck disable=SC2086 { shopt -s nullglob has brew && dir "$(brew --cellar)/* $(brew --caskroom)/*" has emerge && dir "/var/db/pkg/*/*" has Compile && dir "/Programs/*/" has eopkg && dir "/var/lib/eopkg/package/*" has crew && dir "${CREW_PREFIX:-/usr/local}/etc/crew/meta/*.filelist" has pkgtool && dir "/var/log/packages/*" has scratch && dir "/var/lib/scratchpkg/index/*/.pkginfo" has kagami && dir "/var/lib/kagami/pkgs/*" has cave && dir "/var/db/paludis/repositories/cross-installed/*/data/*/ \ /var/db/paludis/repositories/installed/data/*/" shopt -u nullglob } # Other (Needs complex command) has kpm-pkg && ((packages+=$(kpm --get-selections | grep -cv deinstall$))) has guix && { manager=guix-system && tot guix package -p "/run/current-system/profile" -I manager=guix-user && tot guix package -I } has nix-store && { nix-user-pkgs() { nix-store -qR ~/.nix-profile nix-store -qR /etc/profiles/per-user/"$USER" } manager=nix-system && tot nix-store -qR /run/current-system/sw manager=nix-user && tot nix-user-pkgs manager=nix-default && tot nix-store -qR /nix/var/nix/profiles/default } # pkginfo is also the name of a python package manager which is painfully slow. # TODO: Fix this somehow. has pkginfo && tot pkginfo -i # List these last as they accompany regular package managers. has flatpak && tot flatpak list has spm && tot spm list -i has puyo && dir ~/.puyo/installed # Snap hangs if the command is run without the daemon running. # Only run snap if the daemon is also running. has snap && ps -e | grep -qFm 1 snapd >/dev/null && \ pkgs_h=1 tot snap list && ((packages-=1)) # This is the only standard location for appimages. # See: https://github.com/AppImage/AppImageKit/wiki manager=appimage && has appimaged && dir ~/.local/bin/*.appimage ;; "Mac OS X"|"macOS"|MINIX) has brew && { manager="$(color 3) ${reset}" && dir "$(brew --cellar)/* $(brew --caskroom)/*" } has nix-store && { nix-user-pkgs() { nix-store -qR ~/.nix-profile nix-store -qR /etc/profiles/per-user/"$USER" } manager="$(color 4) $(color 1)S${reset}" && tot nix-store -qR /run/current-system/sw manager="$(color 4) U${reset}" && tot nix-user-pkgs } ;; esac if ((packages == 0)); then unset packages elif [[ $package_managers == on ]]; then printf -v packages '%s, ' "${managers[@]}" packages=${packages%,*} elif [[ $package_managers == tiny ]]; then packages+=" (${manager_string%,*})" fi packages=${packages/pacman-key/pacman} } print_info() { poke_info=$(gum style --border normal --padding '0 1' --width 42 "\ $(echo "$(info "$(color 1) OS  " distro)" | tr -d "\n") \ $(echo -e "\n$(info "$(color 2) UP  " uptime)") \ $(echo -e "\n$(info "$(color 3) PKG  " packages)") \ $(echo -e "\n$(info "$(color 4) WM  " wm)") \ $(echo -e "\n$(info "$(color 5) SHELL  " shell)") \ $(echo -e "\n$(info "$(color 6) TERM  " term)") \ $(echo -e "\n$(color 9) EDIT  $(color 7) $EDITOR") \ $(echo -e "\n$(info "$(color 8) MEM  " memory)") ") group_info_entries=$(gum join --vertical "${info}" '' "${poke_info}") print_test "$(gum join --horizontal --align center "${art}" ' ' "${group_info_entries}")" } title_fqdn="off" kernel_shorthand="on" distro_shorthand="tiny" os_arch="off" uptime_shorthand="tiny" memory_percent="off" memory_unit="gib" package_managers="on" shell_path="off" shell_version="off" speed_type="bios_limit" speed_shorthand="on" cpu_brand="on" cpu_speed="on" cpu_cores="logical" cpu_temp="off" gpu_brand="on" gpu_type="all" refresh_rate="on" gtk_shorthand="off" gtk2="on" gtk3="on" public_ip_host="http://ident.me" public_ip_timeout=2 de_version="on" disk_show=('/' "/dev/sda1") disk_subtitle="mount" disk_percent="on" music_player="auto" song_format="%artist% - %album% - %title%" song_shorthand="off" mpc_args=() colors=(distro) bold="on" underline_enabled="on" underline_char="─" separator=" " block_range=(0 15) color_blocks="on" block_width=3 block_height=1 col_offset="auto" bar_char_elapsed="-" bar_char_total="=" bar_border="on" bar_length=15 bar_color_elapsed="distro" bar_color_total="distro" cpu_display="off" memory_display="off" battery_display="off" disk_display="off" image_backend="off" image_source="auto" ascii_distro="auto" ascii_colors=(distro) ascii_bold="on" image_loop="off" thumbnail_dir="${XDG_CACHE_HOME:-${HOME}/.cache}/thumbnails/neofetch" crop_mode="normal" crop_offset="center" image_size="auto" gap=3 yoffset=0 xoffset=0 background_color= stdout="off"