-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev-status.sh
More file actions
executable file
·207 lines (183 loc) · 6.73 KB
/
Copy pathdev-status.sh
File metadata and controls
executable file
·207 lines (183 loc) · 6.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/env bash
set -euo pipefail
PROJECT_NAME="Bitcoin-Script-33"
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$PROJECT_ROOT"
if [[ -t 1 ]]; then
RESET=$'\033[0m'
BOLD=$'\033[1m'
DIM=$'\033[2m'
CYAN=$'\033[36m'
BLUE=$'\033[94m'
GREEN=$'\033[32m'
ORANGE=$'\033[38;5;208m'
PURPLE=$'\033[35m'
YELLOW=$'\033[33m'
WHITE=$'\033[97m'
RED=$'\033[31m'
else
RESET=""
BOLD=""
DIM=""
CYAN=""
BLUE=""
GREEN=""
ORANGE=""
PURPLE=""
YELLOW=""
WHITE=""
RED=""
fi
line() {
printf '%s%s%s\n' "$DIM" '────────────────────────────────────────────────────────────────────────────' "$RESET"
}
print_window_header() {
printf '\n%s●%s %s●%s %s●%s %sdev-status.sh — %s%s\n' \
"$RED" "$RESET" "$YELLOW" "$RESET" "$GREEN" "$RESET" "$DIM" "$PROJECT_NAME" "$RESET"
line
}
print_prompt() {
printf '\n%s%s@Mac%s %s~%s ./scripts/dev-status.sh\n\n' "$GREEN" "giancarlovizhnay" "$RESET" "$DIM" "$RESET"
}
print_ghost_frame_1() {
cat <<EOF
${CYAN}${DIM} .........
${CYAN}${DIM} .:+#############+:.
${CYAN} .+#####################+.
${CYAN} +#########${WHITE} oo ${CYAN}#########+
${CYAN} ##########${WHITE} oo ${CYAN}##########
${BLUE} .###########################.
${BLUE} #############################
${BLUE} #############################
${BLUE} #######${DIM}::::${BLUE}#########${DIM}::::${BLUE}#######
${BLUE} #####:${DIM} ${BLUE}:#####:${DIM} ${BLUE}:#####
${BLUE}${DIM} .###: :###: :###.
${BLUE}${DIM} :+. .:+. .+:
${CYAN}${DIM} ghost process waking${RESET}
EOF
}
print_ghost_frame_2() {
cat <<EOF
${CYAN}${DIM} .........
${CYAN}${DIM} .:+#############+:.
${CYAN} .+#####################+.
${CYAN} +#########${WHITE} -- ${CYAN}#########+
${CYAN} ##########${WHITE} -- ${CYAN}##########
${BLUE} .###########################.
${BLUE} #############################
${BLUE} #############################
${BLUE} #######${DIM}::::${BLUE}#########${DIM}::::${BLUE}#######
${BLUE} #####:${DIM} ${BLUE}:#####:${DIM} ${BLUE}:#####
${BLUE}${DIM} .###: :###: :###.
${BLUE}${DIM} :+. .:+. .+:
${CYAN}${DIM} ghost process blinking${RESET}
EOF
}
print_ghost_frame_3() {
cat <<EOF
${CYAN}${DIM} .........
${CYAN}${DIM} .:+#############+:.
${CYAN} .+#####################+.
${CYAN} +#########${WHITE} OO ${CYAN}#########+
${CYAN} ##########${WHITE} OO ${CYAN}##########
${BLUE} .###########################.
${BLUE} #############################
${BLUE} #############################
${BLUE} #######${DIM}::::${BLUE}#########${DIM}::::${BLUE}#######
${BLUE} #####:${DIM} ${BLUE}:#####:${DIM} ${BLUE}:#####
${BLUE}${DIM} .###: :###: :###.
${BLUE}${DIM} :+. .:+. .+:
${CYAN}${DIM} ghost process online${RESET}
EOF
}
print_ghost() {
print_ghost_frame_3
}
animate_ghost() {
[[ -t 1 ]] || return 0
[[ "${NO_GHOST_ANIMATION:-0}" == "1" ]] && return 0
local start_line
start_line="$(tput sc 2>/dev/null || true)"
tput civis 2>/dev/null || true
for _ in 1 2; do
tput rc 2>/dev/null || true
print_ghost_frame_1
sleep 0.16
tput rc 2>/dev/null || true
print_ghost_frame_2
sleep 0.12
tput rc 2>/dev/null || true
print_ghost_frame_3
sleep 0.18
done
tput cnorm 2>/dev/null || true
printf '\n'
}
collect_system_info() {
local os host kernel uptime shell_name terminal_name cpu memory disk local_ip
os="$(sw_vers -productName 2>/dev/null || uname -s) $(sw_vers -productVersion 2>/dev/null || true)"
host="$(sysctl -n hw.model 2>/dev/null || hostname)"
kernel="$(uname -sr 2>/dev/null || printf 'unknown')"
uptime="$(uptime | sed 's/^.*up //' | sed 's/, [0-9]* user.*$//' | sed 's/, load averages.*$//' 2>/dev/null || printf 'unknown')"
shell_name="${SHELL:-unknown}"
shell_name="${shell_name##*/}"
terminal_name="${TERM_PROGRAM:-Terminal}"
cpu="$(sysctl -n machdep.cpu.brand_string 2>/dev/null || printf 'Apple Silicon')"
memory="$(( $(sysctl -n hw.memsize 2>/dev/null || echo 0) / 1024 / 1024 / 1024 )) GiB"
disk="$(df -h / | awk 'NR==2 {print $3 " / " $2 " (" $5 ")"}' 2>/dev/null || printf 'unknown')"
local_ip="$(ipconfig getifaddr en0 2>/dev/null || printf 'offline')"
printf '%s%s%s%s\n' "$BOLD" "$CYAN" "giancarlovizhnay@Mac" "$RESET"
printf '%s\n' "────────────────────────"
printf '%sOS%s : %s\n' "$ORANGE" "$RESET" "$os"
printf '%sHost%s : %s\n' "$ORANGE" "$RESET" "$host"
printf '%sKernel%s : %s\n' "$ORANGE" "$RESET" "$kernel"
printf '%sUptime%s : %s\n' "$ORANGE" "$RESET" "$uptime"
printf '%sShell%s : %s\n' "$ORANGE" "$RESET" "$shell_name"
printf '%sTerminal%s : %s\n' "$ORANGE" "$RESET" "$terminal_name"
printf '%sCPU%s : %s\n' "$ORANGE" "$RESET" "$cpu"
printf '%sMemory%s : %s\n' "$ORANGE" "$RESET" "$memory"
printf '%sDisk (/)%s : %s\n' "$ORANGE" "$RESET" "$disk"
printf '%sLocal IP%s : %s\n' "$ORANGE" "$RESET" "$local_ip"
}
print_status_grid() {
printf '%s%s=== %s Dev Status ===%s\n\n' "$BOLD" "$CYAN" "$PROJECT_NAME" "$RESET"
paste <(print_ghost) <(collect_system_info) | sed 's/^/ /'
}
print_repo_status() {
printf '\n%s=== Repository ===%s\n' "$PURPLE" "$RESET"
line
printf '%sPath%s : %s%s%s\n' "$DIM" "$RESET" "$CYAN" "$PROJECT_ROOT" "$RESET"
if command -v git >/dev/null 2>&1 && git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
local branch commit
branch="$(git branch --show-current 2>/dev/null || printf 'unknown')"
commit="$(git rev-parse --short HEAD 2>/dev/null || printf 'unknown')"
printf '%sBranch%s : %s%s%s\n' "$DIM" "$RESET" "$GREEN" "$branch" "$RESET"
printf '%sCommit%s : %s%s%s\n' "$DIM" "$RESET" "$YELLOW" "$commit" "$RESET"
if git diff --quiet --ignore-submodules -- 2>/dev/null; then
printf '%sWorking tree%s : %s✓ clean%s\n' "$DIM" "$RESET" "$GREEN" "$RESET"
else
printf '%sWorking tree%s : %shas local changes%s\n' "$DIM" "$RESET" "$ORANGE" "$RESET"
fi
else
printf 'Git: unavailable or not inside a repository\n'
fi
}
print_project_files() {
printf '\n%s=== Project Files ===%s\n' "$CYAN" "$RESET"
line
find . \
-path './.git' -prune -o \
-path './node_modules' -prune -o \
-path './dist' -prune -o \
-path './build' -prune -o \
-maxdepth 2 \
-type f \
-print | sort | sed 's#^./#├── #'
}
print_window_header
print_prompt
animate_ghost
print_status_grid
print_repo_status
print_project_files
printf '\n%s✓ Done.%s\n' "$GREEN" "$RESET"