Dotfiles update 2025-12-22 12:07

This commit is contained in:
Aaron D. Lee
2025-12-22 12:07:08 -05:00
parent 9e916c6c54
commit cd2a162981
12 changed files with 31 additions and 31 deletions

View File

@@ -21,17 +21,17 @@ source "$DOTFILES_HOME/zsh/lib/colors.zsh" 2>/dev/null || {
print_header() { print_header() {
if declare -f df_print_header &>/dev/null; then if declare -f df_print_header &>/dev/null; then
df_print_header "dotfiles-stats" df_print_header "dotfiles-stats "
else else
local user="${USER:-root}" local user="${USER:-root}"
local hostname="${HOSTNAME:-$(hostname -s 2>/dev/null)}" local hostname="${HOSTNAME:-$(hostname -s 2>/dev/null)}"
local datetime=$(date '+%a %b %d %H:%M') local datetime=$(date '+%a %b %d %H:%M')
local width=66 local width=66
local hline="" && for ((i=0; i<width; i++)); do hline+="═"; done local hline="" && for ((i=0; i<width; i++)); do hline+="═"; done
echo "" echo ""
echo -e "${DF_GREY}${hline}${DF_NC}" echo -e "${DF_GREY}${hline}${DF_NC}"
echo -e "${DF_GREY}${DF_NC} ${DF_BOLD}${DF_LIGHT_BLUE}${user}@${hostname}${DF_NC} ${DF_DIM}dotfiles-stats${DF_NC} ${datetime} ${DF_GREY}${DF_NC}" echo -e "${DF_GREY}${DF_NC} ${DF_BOLD}${DF_LIGHT_BLUE}${user}@${hostname}${DF_NC} ${DF_DIM}dotfiles-stats! ${DF_NC} ${datetime} ${DF_GREY}${DF_NC}"
echo -e "${DF_GREY}${hline}${DF_NC}" echo -e "${DF_GREY}${hline}${DF_NC}"
echo "" echo ""
fi fi
@@ -62,48 +62,48 @@ get_history() {
show_dashboard() { show_dashboard() {
print_section "Command History Dashboard" print_section "Command History Dashboard"
local total=$(get_history | wc -l) local total=$(get_history | wc -l)
local unique=$(get_history | sort | uniq | wc -l) local unique=$(get_history | sort | uniq | wc -l)
echo "" echo ""
echo -e " ${DF_CYAN}Total Commands:${DF_NC} $total" echo -e " ${DF_CYAN}Total Commands:${DF_NC} $total"
echo -e " ${DF_CYAN}Unique Commands:${DF_NC} $unique" echo -e " ${DF_CYAN}Unique Commands:${DF_NC} $unique"
echo "" echo ""
print_section "Top 15 Commands" print_section "Top 15 Commands"
get_history | awk '{print $1}' | sort | uniq -c | sort -rn | head -15 | while read count cmd; do get_history | awk '{print $1}' | sort | uniq -c | sort -rn | head -15 | while read count cmd; do
local percent=$((count * 100 / total)) local percent=$((count * 100 / total))
local bar_length=$((percent / 5)) local bar_length=$((percent / 5))
local bar=$(printf '█%.0s' $(seq 1 $bar_length)) local bar=$(printf '█%.0s' $(seq 1 $bar_length))
printf " %-20s ${DF_GREEN}%5d${DF_NC} ${DF_MAGENTA}%3d%%${DF_NC} ${bar}\n" "$cmd" "$count" "$percent" printf " %-20s ${DF_GREEN}%5d${DF_NC} ${DF_MAGENTA}%3d%%${DF_NC} ${bar}\n" "$cmd" "$count" "$percent"
done done
echo "" echo ""
} }
show_top_n() { show_top_n() {
local n="${1:-20}" local n="${1:-20}"
print_section "Top $n Commands" print_section "Top $n Commands"
local total=$(get_history | wc -l) local total=$(get_history | wc -l)
get_history | awk '{print $1}' | sort | uniq -c | sort -rn | head -"$n" | \ get_history | awk '{print $1}' | sort | uniq -c | sort -rn | head -"$n" | \
while read count cmd; do while read count cmd; do
local percent=$((count * 100 / total)) local percent=$((count * 100 / total))
printf " ${DF_YELLOW}%4d${DF_NC} %-30s ${DF_CYAN}%3d%%${DF_NC}\n" "$count" "$cmd" "$percent" printf " ${DF_YELLOW}%4d${DF_NC} %-30s ${DF_CYAN}%3d%%${DF_NC}\n" "$count" "$cmd" "$percent"
done done
echo "" echo ""
} }
show_suggestions() { show_suggestions() {
print_section "Suggested Aliases" print_section "Suggested Aliases"
local total=$(get_history | wc -l) local total=$(get_history | wc -l)
echo "" echo ""
get_history | awk '{print $1}' | sort | uniq -c | sort -rn | head -20 | \ get_history | awk '{print $1}' | sort | uniq -c | sort -rn | head -20 | \
while read count cmd; do while read count cmd; do
@@ -111,38 +111,38 @@ show_suggestions() {
printf " ${DF_YELLOW}Suggestion:${DF_NC} ${DF_GREEN}alias ${cmd:0:2}='$cmd'${DF_NC} (used $count times)\n" printf " ${DF_YELLOW}Suggestion:${DF_NC} ${DF_GREEN}alias ${cmd:0:2}='$cmd'${DF_NC} (used $count times)\n"
fi fi
done done
echo "" echo ""
} }
show_breakdown() { show_breakdown() {
print_section "Command Breakdown" print_section "Command Breakdown"
echo "" echo ""
echo -e " ${DF_CYAN}Git Commands:${DF_NC}" echo -e " ${DF_CYAN}Git Commands:${DF_NC}"
get_history | grep "^git" | wc -l | xargs printf " %d\n" get_history | grep "^git" | wc -l | xargs printf " %d\n"
echo -e " ${DF_CYAN}Navigation (cd):${DF_NC}" echo -e " ${DF_CYAN}Navigation (cd):${DF_NC}"
get_history | grep "^cd" | wc -l | xargs printf " %d\n" get_history | grep "^cd" | wc -l | xargs printf " %d\n"
echo -e " ${DF_CYAN}File Operations (ls):${DF_NC}" echo -e " ${DF_CYAN}File Operations (ls):${DF_NC}"
get_history | grep "^ls" | wc -l | xargs printf " %d\n" get_history | grep "^ls" | wc -l | xargs printf " %d\n"
echo -e " ${DF_CYAN}Package Management (pacman/paru/yay):${DF_NC}" echo -e " ${DF_CYAN}Package Management (pacman/paru/yay):${DF_NC}"
get_history | grep -E "^(pacman|paru|yay)" | wc -l | xargs printf " %d\n" get_history | grep -E "^(pacman|paru|yay)" | wc -l | xargs printf " %d\n"
echo -e " ${DF_CYAN}Editing (vim/nvim):${DF_NC}" echo -e " ${DF_CYAN}Editing (vim/nvim):${DF_NC}"
get_history | grep -E "^(vim|nvim)" | wc -l | xargs printf " %d\n" get_history | grep -E "^(vim|nvim)" | wc -l | xargs printf " %d\n"
echo -e " ${DF_CYAN}Dotfiles Commands (dotfiles-):${DF_NC}" echo -e " ${DF_CYAN}Dotfiles Commands (dotfiles-):${DF_NC}"
get_history | grep "^dotfiles-" | wc -l | xargs printf " %d\n" get_history | grep "^dotfiles-" | wc -l | xargs printf " %d\n"
echo "" echo ""
} }
show_heatmap() { show_heatmap() {
print_section "Activity by Hour" print_section "Activity by Hour"
echo "" echo ""
if [[ -f "$HOME/.zsh_history" ]]; then if [[ -f "$HOME/.zsh_history" ]]; then
grep "^:" "$HOME/.zsh_history" | awk -F'[: ]' '{print $2}' | \ grep "^:" "$HOME/.zsh_history" | awk -F'[: ]' '{print $2}' | \
@@ -154,13 +154,13 @@ show_heatmap() {
else else
echo " ${DF_YELLOW}${DF_NC} Zsh history file required for hourly breakdown" echo " ${DF_YELLOW}${DF_NC} Zsh history file required for hourly breakdown"
fi fi
echo "" echo ""
} }
show_dirs() { show_dirs() {
print_section "Most Visited Directories" print_section "Most Visited Directories"
echo "" echo ""
if [[ -f "$HOME/.zsh_history" ]]; then if [[ -f "$HOME/.zsh_history" ]]; then
grep "cd " "$HOME/.zsh_history" | awk '{print $NF}' | sort | uniq -c | \ grep "cd " "$HOME/.zsh_history" | awk '{print $NF}' | sort | uniq -c | \
@@ -170,28 +170,28 @@ show_dirs() {
else else
echo " ${DF_YELLOW}${DF_NC} Zsh history file required" echo " ${DF_YELLOW}${DF_NC} Zsh history file required"
fi fi
echo "" echo ""
} }
show_git_breakdown() { show_git_breakdown() {
print_section "Git Command Breakdown" print_section "Git Command Breakdown"
echo "" echo ""
local total=$(get_history | grep "^git" | wc -l) local total=$(get_history | grep "^git" | wc -l)
if [[ $total -eq 0 ]]; then if [[ $total -eq 0 ]]; then
echo " ${DF_YELLOW}No git commands found${DF_NC}" echo " ${DF_YELLOW}No git commands found${DF_NC}"
return return
fi fi
get_history | grep "^git " | awk '{print $2}' | sort | uniq -c | sort -rn | \ get_history | grep "^git " | awk '{print $2}' | sort | uniq -c | sort -rn | \
head -10 | while read count subcmd; do head -10 | while read count subcmd; do
local percent=$((count * 100 / total)) local percent=$((count * 100 / total))
printf " ${DF_YELLOW}git %-15s${DF_NC} ${DF_CYAN}%4d${DF_NC} (${DF_MAGENTA}%3d%%${DF_NC})\n" \ printf " ${DF_YELLOW}git %-15s${DF_NC} ${DF_CYAN}%4d${DF_NC} (${DF_MAGENTA}%3d%%${DF_NC})\n" \
"$subcmd" "$count" "$percent" "$subcmd" "$count" "$percent"
done done
echo "" echo ""
} }
@@ -201,7 +201,7 @@ show_git_breakdown() {
main() { main() {
print_header print_header
case "${1:-dashboard}" in case "${1:-dashboard}" in
dashboard) dashboard)
show_dashboard show_dashboard

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
zsh/functions/motd.zsh.zwc Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.