diyfetch
This file
The walk stopped after 200 commits: lines older than 6837ed2 point at it.
feat(deps): bump github.com/charmbracelet/bubbletea from 0.27.0 to 1.0.0 (#661)dependabot[bot]before adoption6837ed2
lines 1–100why, one step back1#!/bin/sh23# ____ _____ ____ _ _4# | _ \_ _\ \ / / _| ___| |_ ___| |__5# | | | | | \ V / |_ / _ \ __/ __| '_ \6# | |_| | | | || _| __/ || (__| | | |7# |____/___| |_||_| \___|\__\___|_| |_|8#9# About:10# DIYfetch it the shell script template for writing fetch tool11# utilizing `gum join` command (https://github.com/charmbracelet/gum#join).12#13# This script is written in POSIX-shell for portability14# feel free to switch it to any scripting language that you prefer.15#16# Note:17# When copy ANSI string from random script make sure to replace "\033" and "\e" to ""18# or wrap it in `$(printf '%b' "<ansi_string>")`.19#20# URL: https://github.com/info-mono/diyfetch212223# Prepare ------------------------------------------------------------------------------------------2425# You can lookup the color codes on https://wikipedia.org/wiki/ANSI_escape_code#8-bit26main_color=42728# You can add some eye candy icons with Emoji of use Nerd Fonts (https://www.nerdfonts.com).29info=$(gum style "[1;38;5;${main_color}m${USER}[0m@[1;38;5;${main_color}m$(hostname)[0m30----------------31[1;38;5;${main_color}mOS: [0m<your_os>32[1;38;5;${main_color}mKERNEL: [0m$(uname -sr)33[1;38;5;${main_color}mUPTIME: [0m$(uptime -p | cut -c 4-)34[1;38;5;${main_color}mSHELL: [0m$(basename "${SHELL}")35[1;38;5;${main_color}mEDITOR: [0m$(basename "${EDITOR:-<your_editor>}")36[1;38;5;${main_color}mDE: [0m<your_de>37[1;38;5;${main_color}mWM: [0m<your_wm>38[1;38;5;${main_color}mTERMINAL: [0m<your_terminal>")3940# You can get OS arts on https://github.com/info-mono/os-ansi41# copy the raw data of the .ansi file then paste it down below.42art=$(gum style ' [34m___[0m43 [34m([0m.. [34m|[0m44 [34m([33m<> [34m|[0m45 [34m/ [0m__ [34m\[0m46 [34m( [0m/ \[34m/ |[0m47[33m_[34m/\ [0m__)[34m/[33m_[34m)[0m48[33m\/[34m-____[33m\/[0m')4950# You can generate colorstrip using https://github.com/info-mono/colorstrip51color=$(gum style '[0;30m███[0;31m███[0;32m███[0;33m███[0;34m███[0;35m███[0;36m███[0;37m███[0m52[0;1;90m███[0;1;91m███[0;1;92m███[0;1;93m███[0;1;94m███[0;1;95m███[0;1;96m███[0;1;97m███[0m')535455# Display ------------------------------------------------------------------------------------------5657# The code in this section is to display the fetch adaptively to the terminal's size.58# If you just want a static fetch display, you can just use something like this:59#60# group_info_color=$(gum join --vertical "${info}" '' "${color}")61# gum join --horizontal --align center ' ' "${art}" ' ' "${group_info_color}"6263terminal_size=$(stty size)64terminal_height=${terminal_size% *}65terminal_width=${terminal_size#* }6667# Acknowledge of how high the shell prompt is so the prompt don't push the fetch out.68prompt_height=${PROMPT_HEIGHT:-1}6970print_test() {71 no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')7273 [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 174 [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 17576 gum style --align center --width="${terminal_width}" "${1}" ''77 printf '%b' "\033[A"7879 exit 080}818283# Paper layout84print_test "$(gum join --vertical --align center "${art}" '' "${info}" '' "${color}")"8586# Classic layout87group_info_color=$(gum join --vertical "${info}" '' "${color}")88print_test "$(gum join --horizontal --align center "${art}" ' ' "${group_info_color}")"8990# Hybrid layout91group_art_info=$(gum join --horizontal --align center "${art}" ' ' "${info}")92print_test "$(gum join --vertical --align center "${group_art_info}" '' "${color}")"9394# Other layout95print_test "$(gum join --vertical --align center "${art}" '' "${info}")"96print_test "${group_art_info}"97print_test "${group_info_color}"98print_test "${info}"99100exit 1