.
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ## 💡 About
7 |
8 | **DIYfetch** it the shell script template for writing adaptive fetch tool utilizing
9 | [Gum's join command](https://github.com/charmbracelet/gum#join).
10 |
11 | ## 🚀 Setup
12 |
13 | ### 🧾 Dependencies
14 |
15 | - [POSIX compliance shell (`sh`, `bash`, `zsh`, ...)](https://wikipedia.org/wiki/Unix_shell)
16 | - [Gum](https://github.com/charmbracelet/gum) ([installation guide](https://github.com/charmbracelet/gum#installation))
17 |
18 | ### 📥 Download
19 |
20 | Download the [`diyfetch`](https://github.com/info-mono/diyfetch/blob/main/diyfetch) file:
21 |
22 | ```sh
23 | curl https://raw.githubusercontent.com/info-mono/diyfetch/main/diyfetch > ~/.local/bin/diyfetch
24 | chmod +x ~/.local/bin/diyfetch
25 | ```
26 |
27 | > **Note** feel free to change the file name to what ever you want.
28 |
29 | ### ⚙️ Customize
30 |
31 | Open the fetch script with your favorite editor then add, delete and change whatever you prefer.
32 | The script contain detailed guide to customize it.
33 |
34 | ### ⌨️ Usage
35 |
36 | Finally, run the fetch script in the terminal:
37 |
38 | ```sh
39 | diyfetch
40 | ```
41 |
42 | ## 🖼️ Showcases
43 |
44 | Here are some examples, you can find their script in [`examples/`](examples).
45 |
46 | ### [Insert Name](examples/insertname)
47 |
48 | This example is inspired by [Insert Name from Neofetch themes](https://github.com/Chick2D/neofetch-themes#insert-name).
49 |
50 |
51 |
52 |
53 |
54 |
55 | ### [Idlifetch](examples/idlifetch)
56 |
57 | This example is inspired by [Idlifetch from Neofetch themes](https://github.com/Chick2D/neofetch-themes#idlifetch).
58 |
59 |
60 |
61 |
62 |
63 |
64 | ### [Ozozfetch](examples/ozozfetch)
65 |
66 | This example is inspired by [Ozozfetch from Neofetch themes](https://github.com/Chick2D/neofetch-themes#ozozfetch).
67 |
68 |
69 |
70 |
71 |
72 |
73 | ### [Fm6000](examples/fm6000)
74 |
75 | This example is inspired by [Fetch-master 6000](https://github.com/anhsirk0/fetch-master-6000).
76 |
77 |
78 |
79 |
80 |
81 |
82 | ### [Laundryfetch](examples/laundryfetch)
83 |
84 | A tiny fetch I make to celebrate my No.1 victory at the local game jam.
85 |
86 | > I buy a smart washing machine for mommy with the prize money.
87 |
88 |
89 |
90 |
91 |
92 |
93 | ### [Timefetch](examples/timefetch)
94 |
95 | Why stop at system informations. You can fetch a bunch of time related information as well!
96 |
97 |
98 |
99 |
100 |
101 |
102 | > **Note**
103 | > Requirements: [`figlet`](https://www.figlet.org).
104 |
105 | ### [Weatherfetch](examples/weatherfetch)
106 |
107 | This example utilize [`wttr.in`'s API](https://github.com/chubin/wttr.in#json-output)
108 | with [Wego's ansi arts](https://github.com/schachmat/wego).
109 |
110 |
111 |
112 |
113 |
114 |
115 | > **Note**
116 | > Requirements: [`jq`](https://stedolan.github.io/jq).
117 |
118 | ### [Pokefetch](examples/pokefetch)
119 |
120 | Poke~~dex~~ fetch! This example utilize [PokeAPI](https://pokeapi.co)
121 | and [Pokemon colorscripts](https://gitlab.com/phoneybadger/pokemon-colorscripts).
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 | > **Note**
131 | > Requirements: [`jq`](https://stedolan.github.io/jq).
132 |
133 | ## 💌 Credits
134 |
135 | Special thanks to:
136 | - [**Neofetch Themes**](https://github.com/Chick2D/neofetch-themes) by [Chick Chan](https://github.com/Chick2D)
137 | - [**Neofetch**](https://github.com/dylanaraps/neofetch) by [Dylan](https://github.com/dylanaraps)
138 | - [**Pfetch**](https://github.com/dylanaraps/pfetch) also by [Dylan](https://github.com/dylanaraps)
139 | - [**Ufetch**](https://gitlab.com/jschx/ufetch) by [Jschx](https://gitlab.com/jschx)
140 | - [**Pure sh bible**](https://github.com/dylanaraps/pure-sh-bible) also by [Dylan](https://github.com/dylanaraps)
141 | - [**ShellCheck**](https://www.shellcheck.net) also by [Vidar Holen](https://github.com/koalaman)
142 |
143 | 🥚
144 |
145 |
146 |
151 |
152 |
--------------------------------------------------------------------------------
/diyfetch:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # ____ _____ ____ _ _
4 | # | _ \_ _\ \ / / _| ___| |_ ___| |__
5 | # | | | | | \ V / |_ / _ \ __/ __| '_ \
6 | # | |_| | | | || _| __/ || (__| | | |
7 | # |____/___| |_||_| \___|\__\___|_| |_|
8 | #
9 | # About:
10 | # DIYfetch it the shell script template for writing fetch tool
11 | # utilizing `gum join` command (https://github.com/charmbracelet/gum#join).
12 | #
13 | # This script is written in POSIX-shell for portability
14 | # 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' "")`.
19 | #
20 | # URL: https://github.com/info-mono/diyfetch
21 |
22 |
23 | # Prepare ------------------------------------------------------------------------------------------
24 |
25 | # You can lookup the color codes on https://wikipedia.org/wiki/ANSI_escape_code#8-bit
26 | main_color=4
27 |
28 | # You can add some eye candy icons with Emoji of use Nerd Fonts (https://www.nerdfonts.com).
29 | info=$(gum style "[1;38;5;${main_color}m${USER}[0m@[1;38;5;${main_color}m$(hostname)[0m
30 | ----------------
31 | [1;38;5;${main_color}mOS: [0m
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:-}")
36 | [1;38;5;${main_color}mDE: [0m
37 | [1;38;5;${main_color}mWM: [0m
38 | [1;38;5;${main_color}mTERMINAL: [0m")
39 |
40 | # You can get OS arts on https://github.com/info-mono/os-ansi
41 | # copy the raw data of the .ansi file then paste it down below.
42 | art=$(gum style ' [34m___[0m
43 | [34m([0m.. [34m|[0m
44 | [34m([33m<> [34m|[0m
45 | [34m/ [0m__ [34m\[0m
46 | [34m( [0m/ \[34m/ |[0m
47 | [33m_[34m/\ [0m__)[34m/[33m_[34m)[0m
48 | [33m\/[34m-____[33m\/[0m')
49 |
50 | # You can generate colorstrip using https://github.com/info-mono/colorstrip
51 | color=$(gum style '[0;30m███[0;31m███[0;32m███[0;33m███[0;34m███[0;35m███[0;36m███[0;37m███[0m
52 | [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')
53 |
54 |
55 | # Display ------------------------------------------------------------------------------------------
56 |
57 | # 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}"
62 |
63 | terminal_size=$(stty size)
64 | terminal_height=${terminal_size% *}
65 | terminal_width=${terminal_size#* }
66 |
67 | # Acknowledge of how high the shell prompt is so the prompt don't push the fetch out.
68 | prompt_height=${PROMPT_HEIGHT:-1}
69 |
70 | print_test() {
71 | no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')
72 |
73 | [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1
74 | [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1
75 |
76 | gum style --align center --width="${terminal_width}" "${1}" ''
77 | printf '%b' "\033[A"
78 |
79 | exit 0
80 | }
81 |
82 |
83 | # Paper layout
84 | print_test "$(gum join --vertical --align center "${art}" '' "${info}" '' "${color}")"
85 |
86 | # Classic layout
87 | group_info_color=$(gum join --vertical "${info}" '' "${color}")
88 | print_test "$(gum join --horizontal --align center "${art}" ' ' "${group_info_color}")"
89 |
90 | # Hybrid layout
91 | group_art_info=$(gum join --horizontal --align center "${art}" ' ' "${info}")
92 | print_test "$(gum join --vertical --align center "${group_art_info}" '' "${color}")"
93 |
94 | # Other layout
95 | print_test "$(gum join --vertical --align center "${art}" '' "${info}")"
96 | print_test "${group_art_info}"
97 | print_test "${group_info_color}"
98 | print_test "${info}"
99 |
100 | exit 1
--------------------------------------------------------------------------------
/examples/brandfetch:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Prepare ------------------------------------------------------------------------------------------
4 |
5 | title=$(gum style --bold --foreground 12 "$(figlet DIYfetch)")
6 | subtitle=$(gum style --italic --foreground 12 'The ultimate fetch tool template')
7 | info=$(gum join --vertical --align center "${title}" "${subtitle}")
8 |
9 | art=$(gum style --foreground "${main_color}" ' ,~-.
10 | ( ʻ )-. ,~ʻ`-.
11 | ,~ʻ ` ʻ ) ) _( _) )
12 | ( ( [97m.--.===.--.[0m ( ` ʻ )
13 | `[97m.%%.[91m###[97m|[0m888[97m.[31m:[97m`.[0m `-ʻ`~~=~ʻ
14 | [97m/%%/[91m####[97m|[0m8888[97m\[31m::[97m\[0m
15 | [97m|%%/[91m#####[97m|[0m88888[97m\[31m::[97m|[0m
16 | [97m|%%|[91m#####[97m|[0m88888[97m|[31m::[97m|[0m.,-.
17 | [97m\%%|[91m#####[97m|[0m88888[97m|[31m::[97m/[0m )_
18 | [97m\%\[91m#####[97m|[0m88888[97m/[31m:[97m/[0m ( `ʻ )
19 | [97m\%\[91m####[97m|[0m8888[97m/[31m:[97m/[0m( , -ʻ`-.
20 | ,~-. [97m`%\[91m###[97m|[0m888[97m/[31m:[97mʻ[0m( ( ʻ) )
21 | ( ) )_ [97m`\[93m__[97m|[93m__[97m/ʻ[0m `~-~=--~~=ʻ
22 | ( ` ʻ) ) [93m[VVVVV][0m
23 | (_(_.~~~ʻ [97m\|[93m_[97m|/[0m
24 | [93m[XXX][0m
25 | [93m`"""ʻ[0m')
26 |
27 | color=$(gum style '[0;30m [0;31m [0;32m [0;33m [0;34m [0;35m [0;36m [0;37m [0m
28 | [0;90m [0;91m [0;92m [0;93m [0;94m [0;95m [0;96m [0;97m [0m')
29 |
30 |
31 | # Display ------------------------------------------------------------------------------------------
32 |
33 | terminal_size=$(stty size)
34 | terminal_height=${terminal_size% *}
35 | terminal_width=${terminal_size#* }
36 |
37 | prompt_height=${PROMPT_HEIGHT#-1}
38 |
39 | print_test() {
40 | no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')
41 |
42 | [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1
43 | [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1
44 |
45 | gum style --align center --width="${terminal_width}" "${1}" ''
46 | printf '%b' "\033[A"
47 |
48 | exit 0
49 | }
50 |
51 |
52 | # Landscape layout
53 | group_info_color=$(gum join --vertical --align center "${info}" '' "${color}")
54 | print_test "$(gum join --horizontal --align center "${art}" ' ' "${group_info_color}")"
55 |
56 | # Portrait layout
57 | print_test "$(gum join --vertical --align center "${art}" '' "${group_info_color}")"
58 |
59 | # Other layout
60 | print_test "${group_info_color}"
61 | print_test "${info}"
62 |
63 | exit 1
--------------------------------------------------------------------------------
/examples/fm6000:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Prepare ------------------------------------------------------------------------------------------
4 |
5 | info=$(gum style --border rounded --border-foreground 6 --padding '1 2' \
6 | "[1;38;5;2mOS [0m
7 | [1;38;5;4mKERNEL [0m$(uname -sr)
8 | [1;38;5;1mDE [0m
9 | [1;38;5;3mSHELL [0m$(basename "${SHELL}")
10 | [1;38;5;5mUPTIME [0m$(uptime -p | cut -c 4-)
11 | [1;38;5;6mPACKAGES [0m")
12 |
13 | # You can get other art on https://github.com/anhsirk0/fetch-master-6000/tree/master/ascii_arts
14 | art=$(gum style --foreground 6 ' დოოოოოდ
15 | | |
16 | | | ╭
17 | |-Ο Ο-| │
18 | Ͼ ∪ Ͽ │
19 | | | ╯
20 | ˏ`-.ŏ.-´ˎ
21 | @
22 | @')
23 |
24 |
25 | # Display ------------------------------------------------------------------------------------------
26 |
27 | terminal_size=$(stty size)
28 | terminal_height=${terminal_size% *}
29 | terminal_width=${terminal_size#* }
30 |
31 | prompt_height=${PROMPT_HEIGHT:-1}
32 |
33 | print_test() {
34 | no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')
35 |
36 | [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1
37 | [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1
38 |
39 | gum style --align center --width="${terminal_width}" "${1}" ''
40 | printf '%b' "\033[A"
41 |
42 | exit 0
43 | }
44 |
45 |
46 | # Default layout
47 | print_test "$(gum join --horizontal "${art}" "${info}")"
48 |
49 | # Other layout
50 | print_test "${info}"
51 |
52 | exit 1
--------------------------------------------------------------------------------
/examples/idlifetch:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Prepare ------------------------------------------------------------------------------------------
4 |
5 | main_color=4
6 |
7 | title=" [38;5;${main_color}m [0m: [1;38;5;${main_color}m${USER}[0m@[1;38;5;${main_color}m$(hostname)[0m"
8 | body=$(gum style --border normal --border-foreground 7 --padding '0 1' --width 30 \
9 | "[38;5;${main_color}m [0m:
10 | [38;5;${main_color}m [0m:
11 | [38;5;${main_color}m [0m: $(basename "${SHELL}")
12 | [38;5;${main_color}m [0m:
13 | [38;5;${main_color}m神[0m: $(uptime -p | cut -c 4- | cut -d ',' -f -2)
14 | [38;5;${main_color}m [0m: ")
15 | info=$(gum join --vertical "${title}" "${body}")
16 |
17 | art=$(gum style ' [34m___[0m
18 | [34m([0m.. [34m|[0m
19 | [34m([33m<> [34m|[0m
20 | [34m/ [0m__ [34m\[0m
21 | [34m( [0m/ \[34m/ |[0m
22 | [33m_[34m/\ [0m__)[34m/[33m_[34m)[0m
23 | [33m\/[34m-____[33m\/[0m')
24 |
25 | color=$(gum style '[0;30m [0;31m [0;32m [0;33m [0;34m [0;35m [0;36m [0;37m [0m')
26 |
27 |
28 | # Display ------------------------------------------------------------------------------------------
29 |
30 | terminal_size=$(stty size)
31 | terminal_height=${terminal_size% *}
32 | terminal_width=${terminal_size#* }
33 |
34 | prompt_height=${PROMPT_HEIGHT:-1}
35 |
36 | print_test() {
37 | no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')
38 |
39 | [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1
40 | [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1
41 |
42 | gum style --align center --width="${terminal_width}" "${1}" ''
43 | printf '%b' "\033[A"
44 |
45 | exit 0
46 | }
47 |
48 |
49 | # Default layout
50 | group_info_color=$(gum join --vertical --align center "${info}" "${color}")
51 | print_test "$(gum join --horizontal --align center ' ' "${art}" ' ' "${group_info_color}")"
52 |
53 | # Other layout
54 | print_test "$(gum join --horizontal --align center ' ' "${art}" ' ' "${info}")"
55 | print_test "${group_info_color}"
56 | print_test "${info}"
57 |
58 | exit 1
--------------------------------------------------------------------------------
/examples/insertname:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Prepare ------------------------------------------------------------------------------------------
4 |
5 | main_color=11
6 |
7 | info=$(gum style --border normal \
8 | " [38;5;${main_color}m [0m ${USER}@$(hostname)
9 | ───────────────────────────────────
10 | [38;5;${main_color}m [0m
11 | [38;5;${main_color}m [0m
12 | [38;5;${main_color}m [0m
13 | [38;5;${main_color}m [0m
14 | [38;5;${main_color}m塞[0m
15 | [38;5;${main_color}m神[0m $(uptime -p | cut -c 4-)
16 | ───────────────────────────────────
17 | [38;5;${main_color}m [0m
18 | [38;5;${main_color}m [0m
19 | [38;5;${main_color}m [0m
20 | [38;5;${main_color}m [0m
21 | [38;5;${main_color}m [0m $(basename "${SHELL}")")
22 |
23 | art=$(gum style '[34m #####[0m
24 | [34m #######[0m
25 | [34m ##[0mO[34m#[0mO[34m##[0m
26 | [34m #[33m#####[34m#[0m
27 | [34m ##[0m##[33m###[0m##[34m##[0m
28 | [34m #[0m##########[34m##[0m
29 | [34m #[0m############[34m##[0m
30 | [34m #[0m############[34m###[0m
31 | [33m ##[34m#[0m###########[34m##[33m#[0m
32 | [33m######[34m#[0m#######[34m#[33m######[0m
33 | [33m#######[34m#[0m#####[34m#[33m#######[0m
34 | [33m #####[34m#######[33m#####[0m')
35 |
36 | color=$(gum style '[0;91m [0;93m [0;92m [0;96m [0;94m [0;95m [0m')
37 |
38 |
39 | # Display ------------------------------------------------------------------------------------------
40 |
41 | terminal_size=$(stty size)
42 | terminal_height=${terminal_size% *}
43 | terminal_width=${terminal_size#* }
44 |
45 | prompt_height=${PROMPT_HEIGHT:-1}
46 |
47 | print_test() {
48 | no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')
49 |
50 | [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1
51 | [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1
52 |
53 | gum style --align center --width="${terminal_width}" "${1}" ''
54 | printf '%b' "\033[A"
55 |
56 | exit 0
57 | }
58 |
59 |
60 | # Default layout
61 | group_info_color=$(gum join --vertical --align center "${info}" "${color}")
62 | print_test "$(gum join --horizontal --align center "${art}" ' ' "${group_info_color}")"
63 |
64 | # Other layout
65 | print_test "$(gum join --horizontal --align center "${art}" ' ' "${info}")"
66 | print_test "${group_info_color}"
67 | print_test "${info}"
68 |
69 | exit 1
--------------------------------------------------------------------------------
/examples/laundryfetch:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Prepare ------------------------------------------------------------------------------------------
4 |
5 | main_color=15
6 |
7 | info=$(gum style --border normal --padding '0 1' --width 30 --italic --foreground "${main_color}" \
8 | "USER: ${USER}@$(hostname)
9 | UPTIME: $(uptime -p | cut -c 4- | cut -d ',' -f -2)")
10 |
11 | art=$(gum style --foreground "${main_color}" '▄▄▄▄▄▄▄
12 | █▄█▄███
13 | █▀ ▄▀█
14 | █ ▄██ █
15 | ██▄▄▄██')
16 |
17 | color=$(gum style '[0;90mﰨ [0;91mﰨ [0;92mﰨ [0;93mﰨ [0;94mﰨ [0;95mﰨ [0;96mﰨ [0;97mﰨ [0m')
18 |
19 |
20 | # Display ------------------------------------------------------------------------------------------
21 |
22 | terminal_size=$(stty size)
23 | terminal_height=${terminal_size% *}
24 | terminal_width=${terminal_size#* }
25 |
26 | prompt_height=${PROMPT_HEIGHT:-1}
27 |
28 | print_test() {
29 | no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')
30 |
31 | [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1
32 | [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1
33 |
34 | gum style --align center --width="${terminal_width}" "${1}" ''
35 | printf '%b' "\033[A"
36 |
37 | exit 0
38 | }
39 |
40 |
41 | # Landscape layout
42 | group_info_color=$(gum join --vertical --align center "${info}" "${color}")
43 | print_test "$(gum join --horizontal --align center "${art}" ' ' "${group_info_color}")"
44 |
45 | # Portrait layout
46 | print_test "$(gum join --vertical --align center "${art}" '' "${group_info_color}")"
47 |
48 | # Other layout
49 | print_test "${group_info_color}"
50 | print_test "${info}"
51 |
52 | exit 1
--------------------------------------------------------------------------------
/examples/ozozfetch:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Prepare ------------------------------------------------------------------------------------------
4 |
5 | main_color=2
6 |
7 | info=$(gum style "[38;5;${main_color}m [0;1;38;5;${main_color}m${USER}[0m@[1;38;5;${main_color}m$(hostname)[0m
8 | ├─ [38;5;${main_color}m [0m
9 | │ ├─ [38;5;${main_color}m [0m
10 | │ ├─ [38;5;${main_color}m [0m
11 | │ ├─ [38;5;${main_color}m [0m
12 | │ ├─ [38;5;${main_color}m塞[0m
13 | │ └─ [38;5;${main_color}m神[0m $(uptime -p | cut -c 4-)
14 | └─ [38;5;${main_color}m [0m
15 | ├─ [38;5;${main_color}m [0m
16 | ├─ [38;5;${main_color}m [0m
17 | ├─ [38;5;${main_color}m [0m
18 | └─ [38;5;${main_color}m [0m $(basename "${SHELL}")")
19 |
20 | art=$(gum style ' [32m&&[0m
21 | [32m&&&&&[0m
22 | [32m&&&[33m\/[32m& &&&[0m
23 | [32m&&[33m|,/ |/[32m& &&[0m
24 | [32m&&[33m/ / /_[32m& &&[0m
25 | [33m\ { |_____/_[32m&[0m
26 | [33m{ / / [32m&&&[0m
27 | [33m.`. \{___\________\/_\}[0m
28 | [33m\} \}\{ \[0m
29 | [33m}\{\{ \____[32m&[0m
30 | [33m\{\}\{ `[32m&[33m\[32m&&[0m
31 | [33m{{} [32m&&[0m
32 | [33m, -=-~{ .-^- _[0m
33 | [33m`.[0m')
34 |
35 | color=$(gum style '[0;30m███[0;31m███[0;32m███[0;33m███[0;34m███[0;35m███[0;36m███[0;37m███[0m
36 | [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')
37 |
38 |
39 | # Display ------------------------------------------------------------------------------------------
40 |
41 | terminal_size=$(stty size)
42 | terminal_height=${terminal_size% *}
43 | terminal_width=${terminal_size#* }
44 |
45 | prompt_height=${PROMPT_HEIGHT:-1}
46 |
47 | print_test() {
48 | no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')
49 |
50 | [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1
51 | [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1
52 |
53 | gum style --align center --width="${terminal_width}" "${1}" ''
54 | printf '%b' "\033[A"
55 |
56 | exit 0
57 | }
58 |
59 |
60 | # Default layout
61 | group_info_color=$(gum join --vertical --align center "${info}" '' "${color}")
62 | print_test "$(gum join --horizontal --align center "${art}" ' ' "${group_info_color}")"
63 |
64 | # Other layout
65 | print_test "$(gum join --horizontal --align center "${art}" ' ' "${info}")"
66 | print_test "${group_info_color}"
67 | print_test "${info}"
68 |
69 | exit 1
--------------------------------------------------------------------------------
/examples/pokefetch:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Prepare ------------------------------------------------------------------------------------------
4 |
5 | pokemon=${1:-$(shuf -i 1-905 -n 1)}
6 |
7 | data_pokemon=$(curl -fsLS "https://pokeapi.co/api/v2/pokemon/${pokemon}")
8 | data_species=$(curl -fsLS "$(echo "${data_pokemon}" | jq --raw-output .species.url)")
9 |
10 | id=$(echo "${data_species}" | jq --raw-output .id)
11 | name=$(echo "${data_species}" | jq --raw-output '.names | .[] | select(.language.name == "en").name')
12 | category=$(echo "${data_species}" | jq --raw-output '.genera | .[] | select(.language.name == "en").genus')
13 | title="▐[1;7m No.$(printf '%03d' "${id}") [0m▌ [1m${name} - ${category}[0m"
14 |
15 | for type in $(echo "${data_pokemon}" | jq --raw-output '.types | .[].type.name' | tr '[:lower:]' '[:upper:]'); do
16 | case "${type}" in
17 | NORMAL) color=7 ;;
18 | FIRE) color=9 ;;
19 | WATER) color=12 ;;
20 | ELECTRIC) color=11 ;;
21 | GRASS) color=10 ;;
22 | ICE) color=14 ;;
23 | FIGHTING) color=1 ;;
24 | POISON) color=5 ;;
25 | GROUND) color=11 ;;
26 | FLYING) color=6 ;;
27 | PSYCHIC) color=13 ;;
28 | BUG) color=2 ;;
29 | ROCK) color=3 ;;
30 | GHOST) color=4 ;;
31 | DRAGON) color=4 ;;
32 | DARK) color=3 ;;
33 | STEEL) color=8 ;;
34 | FAIRY) color=13 ;;
35 | esac
36 |
37 | types="${types} [7;38;5;${color}m ${type} [0m "
38 | done
39 |
40 | height=$(awk "BEGIN{ print $(echo "${data_pokemon}" | jq --raw-output .height) / 10 }")
41 | weight=$(awk "BEGIN{ print $(echo "${data_pokemon}" | jq --raw-output .weight) / 10 }")
42 | status=$(gum style --align center --width 44 "${types}" "Height: [1m${height}m[0m Weight: [1m${weight}kg[0m")
43 |
44 | info=$(gum join --vertical "${title}" '' "${status}")
45 |
46 | entries=$(gum style --border normal --padding '0 1' --width 42 "$(echo "${data_species}" | \
47 | jq --raw-output 'last(.flavor_text_entries | .[] | select(.language.name == "en")).flavor_text' | tr -d "\n")")
48 |
49 | pokemon_path=$(echo "${data_pokemon}" | jq --raw-output .name)
50 | art=$(gum style "$(curl -fsLS \
51 | "https://gitlab.com/phoneybadger/pokemon-colorscripts/-/raw/main/colorscripts/small/regular/${pokemon_path}" \
52 | | sed -e 's/$/[0m/g')")
53 |
54 |
55 | # Display ------------------------------------------------------------------------------------------
56 |
57 | terminal_size=$(stty size)
58 | terminal_height=${terminal_size% *}
59 | terminal_width=${terminal_size#* }
60 |
61 | prompt_height=${PROMPT_HEIGHT:-1}
62 |
63 | print_test() {
64 | no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')
65 |
66 | [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1
67 | [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1
68 |
69 | gum style --align center --width="${terminal_width}" "${1}" ''
70 | printf '%b' "\033[A"
71 |
72 | exit 0
73 | }
74 |
75 |
76 | # Landscape layout
77 | group_info_entries=$(gum join --vertical "${info}" '' "${entries}")
78 | print_test "$(gum join --horizontal --align center "${art}" ' ' "${group_info_entries}")"
79 |
80 | # Portrait layout
81 | print_test "$(gum join --vertical --align center "${info}" '' "${art}" "${entries}")"
82 |
83 | # Other layout
84 | print_test "${group_info_entries}"
85 |
86 | exit 1
--------------------------------------------------------------------------------
/examples/timefetch:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Prepare ------------------------------------------------------------------------------------------
4 |
5 | main_color=9
6 |
7 | clock=$(gum style --bold --italic --foreground 14 "$(date +%X | figlet -f slant)")
8 |
9 | calendar=$(gum style --border thick --border-foreground "${main_color}" --padding '0 2' "
10 | $(cal --color=always)")
11 |
12 | info=$(gum style --border thick --border-foreground "${main_color}" --padding '0 1' "$(date)")
13 |
14 |
15 | # Display ------------------------------------------------------------------------------------------
16 |
17 | terminal_size=$(stty size)
18 | terminal_height=${terminal_size% *}
19 | terminal_width=${terminal_size#* }
20 |
21 | prompt_height=${PROMPT_HEIGHT:-1}
22 |
23 | print_test() {
24 | no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')
25 |
26 | [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1
27 | [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1
28 |
29 | gum style --align center --width="${terminal_width}" "${1}" ''
30 | printf '%b' "\033[A"
31 |
32 | exit 0
33 | }
34 |
35 |
36 | # Landscape layout
37 | group_clock_info=$(gum join --vertical --align center "${clock}" "${info}")
38 | print_test "$(gum join --horizontal --align center "${group_clock_info}" ' ' "${calendar}")"
39 |
40 | # Portrait layout
41 | print_test "$(gum join --vertical --align center "${clock}" "${calendar}" '' "${info}")"
42 |
43 | # Other layout
44 | print_test "${group_clock_info}"
45 | print_test "${info}"
46 |
47 | exit 1
--------------------------------------------------------------------------------
/examples/weatherfetch:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Prepare ------------------------------------------------------------------------------------------
4 |
5 | main_color=6
6 |
7 | data=$(curl -fsLS "https://wttr.in/$*?format=j1")
8 |
9 | location=$(curl -fsLS "https://wttr.in/$*?format=%l")
10 | description=$(echo "${data}" | jq --raw-output .weather[0].hourly[7].weatherDesc[0].value)
11 | humidity=$(echo "${data}" | jq --raw-output .weather[0].hourly[7].humidity)
12 | temperature=$(echo "${data}" | jq --raw-output .weather[0].hourly[7].tempC)
13 | temperature_feels=$(echo "${data}" | jq --raw-output .weather[0].hourly[7].FeelsLikeC)
14 | wind_speed=$(echo "${data}" | jq --raw-output .weather[0].hourly[7].windspeedKmph)
15 | precipitation=$(echo "${data}" | jq --raw-output .weather[0].hourly[7].precipMM)
16 | pressure=$(echo "${data}" | jq --raw-output .weather[0].hourly[7].pressure)
17 |
18 | case "$(echo "${data}" | jq --raw-output .weather[0].hourly[7].winddir16Point)" in
19 | N) wind_direction='↓' ;;
20 | NNE) wind_direction='↓' ;;
21 | NE) wind_direction='↙' ;;
22 | ENE) wind_direction='↙' ;;
23 | E) wind_direction='←' ;;
24 | ESE) wind_direction='←' ;;
25 | SE) wind_direction='↖' ;;
26 | SSE) wind_direction='↖' ;;
27 | S) wind_direction='↑' ;;
28 | SSW) wind_direction='↑' ;;
29 | SW) wind_direction='↗' ;;
30 | WSW) wind_direction='↗' ;;
31 | W) wind_direction='→' ;;
32 | WNW) wind_direction='→' ;;
33 | NW) wind_direction='↘' ;;
34 | NNW) wind_direction='↘' ;;
35 | esac
36 |
37 | info="[1;38;5;${main_color}m${location}[0m
38 | ----------------
39 | [1;38;5;${main_color}mDescription:[0m ${description}
40 | [1;38;5;${main_color}mHumidity:[0m ${humidity}%
41 | [1;38;5;${main_color}mTemperature:[0m ${temperature}(${temperature_feels})°C
42 | [1;38;5;${main_color}mWind:[0m${wind_direction} ${wind_speed}km/h
43 | [1;38;5;${main_color}mPrecipitation:[0m ${precipitation}mm
44 | [1;38;5;${main_color}mPressure:[0m ${pressure}hPa"
45 |
46 | case "${description}" in
47 | 'Cloudy'*) art_raw='
48 | [38;5;250m .--. [0m
49 | [38;5;250m .-( ). [0m
50 | [38;5;250m (___.__)__) [0m
51 | ' ;;
52 | 'Fog'*) art_raw='
53 | [38;5;251m _ - _ - _ - [0m
54 | [38;5;251m _ - _ - _ [0m
55 | [38;5;251m _ - _ - _ - [0m
56 | ' ;;
57 | 'Heavy rain'*) art_raw='[38;5;240;1m .-. [0m
58 | [38;5;240;1m ( ). [0m
59 | [38;5;240;1m (___(__) [0m
60 | [38;5;21;1m ‚ʻ‚ʻ‚ʻ‚ʻ [0m
61 | [38;5;21;1m ‚ʻ‚ʻ‚ʻ‚ʻ [0m' ;;
62 | 'Heavy showers'*) art_raw='[38;5;226m _`/""[38;5;240;1m.-. [0m
63 | [38;5;226m ,\_[38;5;240;1m( ). [0m
64 | [38;5;226m /[38;5;240;1m(___(__) [0m
65 | [38;5;21;1m ‚ʻ‚ʻ‚ʻ‚ʻ [0m
66 | [38;5;21;1m ‚ʻ‚ʻ‚ʻ‚ʻ [0m' ;;
67 | 'Heavy snow showers'*) art_raw='[38;5;226m _`/""[38;5;240;1m.-. [0m
68 | [38;5;226m ,\_[38;5;240;1m( ). [0m
69 | [38;5;226m /[38;5;240;1m(___(__) [0m
70 | [38;5;255;1m * * * * [0m
71 | [38;5;255;1m * * * * [0m' ;;
72 | 'Heavy snow'*) art_raw='[38;5;240;1m .-. [0m
73 | [38;5;240;1m ( ). [0m
74 | [38;5;240;1m (___(__) [0m
75 | [38;5;255;1m * * * * [0m
76 | [38;5;255;1m * * * * [0m' ;;
77 | 'Light rain'*) art_raw='[38;5;250m .-. [0m
78 | [38;5;250m ( ). [0m
79 | [38;5;250m (___(__) [0m
80 | [38;5;111m ʻ ʻ ʻ ʻ [0m
81 | [38;5;111m ʻ ʻ ʻ ʻ [0m' ;;
82 | 'Light showers'*) art_raw='[38;5;226m _`/""[38;5;250m.-. [0m
83 | [38;5;226m ,\_[38;5;250m( ). [0m
84 | [38;5;226m /[38;5;250m(___(__) [0m
85 | [38;5;111m ʻ ʻ ʻ ʻ [0m
86 | [38;5;111m ʻ ʻ ʻ ʻ [0m' ;;
87 | 'Light sleet showers'*) art_raw='[38;5;226m _`/""[38;5;250m.-. [0m
88 | [38;5;226m ,\_[38;5;250m( ). [0m
89 | [38;5;226m /[38;5;250m(___(__) [0m
90 | [38;5;111m ʻ [38;5;255m*[38;5;111m ʻ [38;5;255m* [0m
91 | [38;5;255m *[38;5;111m ʻ [38;5;255m*[38;5;111m ʻ [0m' ;;
92 | 'Light sleet'*) art_raw='[38;5;250m .-. [0m
93 | [38;5;250m ( ). [0m
94 | [38;5;250m (___(__) [0m
95 | [38;5;111m ʻ [38;5;255m*[38;5;111m ʻ [38;5;255m* [0m
96 | [38;5;255m *[38;5;111m ʻ [38;5;255m*[38;5;111m ʻ [0m' ;;
97 | 'Light snow showers'*) art_raw='[38;5;226m _`/""[38;5;250m.-. [0m
98 | [38;5;226m ,\_[38;5;250m( ). [0m
99 | [38;5;226m /[38;5;250m(___(__) [0m
100 | [38;5;255m * * * [0m
101 | [38;5;255m * * * [0m' ;;
102 | 'Light snow'*) art_raw='[38;5;250m .-. [0m
103 | [38;5;250m ( ). [0m
104 | [38;5;250m (___(__) [0m
105 | [38;5;255m * * * [0m
106 | [38;5;255m * * * [0m' ;;
107 | 'Partly cloudy'*) art_raw='[38;5;226m \ /[0m
108 | [38;5;226m _ /""[38;5;250m.-. [0m
109 | [38;5;226m \_[38;5;250m( ). [0m
110 | [38;5;226m /[38;5;250m(___(__) [0m
111 | ' ;;
112 | 'Sunny'*) art_raw='[38;5;226m \ / [0m
113 | [38;5;226m .-. [0m
114 | [38;5;226m ‒ ( ) ‒ [0m
115 | [38;5;226m `-᾿ [0m
116 | [38;5;226m / \ [0m' ;;
117 | 'Thundery heavy rain'*) art_raw='[38;5;240;1m .-. [0m
118 | [38;5;240;1m ( ). [0m
119 | [38;5;240;1m (___(__) [0m
120 | [38;5;21;1m ‚ʻ[38;5;228;5m⚡[38;5;21;25mʻ‚[38;5;228;5m⚡[38;5;21;25m‚ʻ [0m
121 | [38;5;21;1m ‚ʻ‚ʻ[38;5;228;5m⚡[38;5;21;25mʻ‚ʻ [0m' ;;
122 | 'Thundery showers'*) art_raw='[38;5;226m _`/""[38;5;250m.-. [0m
123 | [38;5;226m ,\_[38;5;250m( ). [0m
124 | [38;5;226m /[38;5;250m(___(__) [0m
125 | [38;5;228;5m ⚡[38;5;111;25mʻ ʻ[38;5;228;5m⚡[38;5;111;25mʻ ʻ [0m
126 | [38;5;111m ʻ ʻ ʻ ʻ [0m' ;;
127 | 'Thundery snow showers'*) art_raw='[38;5;226m _`/""[38;5;250m.-. [0m
128 | [38;5;226m ,\_[38;5;250m( ). [0m
129 | [38;5;226m /[38;5;250m(___(__) [0m
130 | [38;5;255m *[38;5;228;5m⚡[38;5;255;25m *[38;5;228;5m⚡[38;5;255;25m * [0m
131 | [38;5;255m * * * [0m' ;;
132 | 'Very cloudy'*) art_raw='
133 | [38;5;240;1m .--. [0m
134 | [38;5;240;1m .-( ). [0m
135 | [38;5;240;1m (___.__)__) [0m
136 | ' ;;
137 | *) art_raw=' .-.
138 | __)
139 | (
140 | `-᾿
141 | • ' ;;
142 | esac
143 |
144 | art=$(gum style "${art_raw}")
145 |
146 |
147 | # Display ------------------------------------------------------------------------------------------
148 |
149 | terminal_size=$(stty size)
150 | terminal_height=${terminal_size% *}
151 | terminal_width=${terminal_size#* }
152 |
153 | prompt_height=${PROMPT_HEIGHT:-1}
154 |
155 | print_test() {
156 | no_color=$(printf '%b' "${1}" | sed -e 's/\x1B\[[0-9;]*[JKmsu]//g')
157 |
158 | [ "$(printf '%s' "${no_color}" | wc --lines)" -gt $(( terminal_height - prompt_height )) ] && return 1
159 | [ "$(printf '%s' "${no_color}" | wc --max-line-length)" -gt "${terminal_width}" ] && return 1
160 |
161 | gum style --align center --width="${terminal_width}" "${1}" ''
162 | printf '%b' "[A"
163 |
164 | exit 0
165 | }
166 |
167 |
168 | # Landscape layout
169 | print_test "$(gum join --horizontal --align center "${art}" ' ' "${info}")"
170 |
171 | # Portrait layout
172 | print_test "$(gum join --vertical --align center "${art}" '' "${info}")"
173 |
174 | # Other layout
175 | print_test "${info}"
176 |
177 | exit 1
--------------------------------------------------------------------------------