From 3f05afdc672c8fc05b9c69bbea6ab697e7cf44ab Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Sat, 24 Jan 2026 00:35:56 -0500 Subject: [PATCH] Fix MOTD IP detection to use default route Use `ip route get 1` to query the kernel for the source IP of the default route instead of `hostname -i`, which returns 127.0.0.1 when /etc/hosts isn't configured for the hostname. Co-Authored-By: Claude Opus 4.5 --- zsh/functions/motd.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zsh/functions/motd.zsh b/zsh/functions/motd.zsh index 6bc2b2f..6255ffd 100644 --- a/zsh/functions/motd.zsh +++ b/zsh/functions/motd.zsh @@ -116,7 +116,7 @@ show_motd() { echo "${DF_GREY}╒${hline}╕${DF_NC}" local h_left="✦ ${username}@${hostname} " - local h_center=$(hostname -i 2>/dev/null | awk -F" " '{print $1}') + local h_center=$(ip route get 1 2>/dev/null | awk '{print $7; exit}' || hostname -i 2>/dev/null | awk '{print $1}') local h_right="${datetime}" local h_pad=$(((inner - ${#h_left} - ${#h_center} - ${#h_right}) / 2)) local h_spaces=""