From dc6b117016df328d6b47bfe5b25f2d2e8b913990 Mon Sep 17 00:00:00 2001 From: Andrejus Date: Wed, 25 Feb 2026 14:45:21 +0000 Subject: [PATCH] Enhance shell widgets, tmux status, and git colors - Add frecency scoring + git status boost to ^E edit widget - Add network latency indicator to tmux status bar (wifi/wired detection, 10s cache) - Add powerline separators between tmux status sections - Swap git status colors: modified=bluish grey, untracked=amber (prompt, gitconfig, widget) - Remove bold from feature branch name in prompt - Add gw (git show) and gdm (diff against default branch) aliases Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- home/.aliases | 2 ++ home/.gitconfig | 4 ++-- home/.tmux.conf | 4 ++-- home/.tmux/network.sh | 54 +++++++++++++++++++++++++++++++++++++++++++ home/.zsh/prompt.zsh | 6 ++--- home/.zsh/widgets.zsh | 4 ++-- 6 files changed, 65 insertions(+), 9 deletions(-) create mode 100755 home/.tmux/network.sh diff --git a/home/.aliases b/home/.aliases index 4bdde4c..3f93af2 100644 --- a/home/.aliases +++ b/home/.aliases @@ -37,6 +37,8 @@ alias gc='git c' alias gl='git ld' alias ga='git a' alias gr='git r' +alias gw='git show' +gdm() { local base="${1:-$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@refs/remotes/origin/@@' || echo main)}"; git diff "${base}...HEAD"; } # fzf workflows gb() { local b; b="$(git branch --all --sort=-committerdate --format='%(refname:short)' | fzf --preview 'git log --oneline --color -20 {}')" && git checkout "${b#origin/}"; } diff --git a/home/.gitconfig b/home/.gitconfig index eaf4663..9d51c5c 100644 --- a/home/.gitconfig +++ b/home/.gitconfig @@ -50,8 +50,8 @@ [color "status"] added = "#2CB494" - changed = "#F88C14" - untracked = "#808080" italic + changed = "#8787AF" + untracked = "#F88C14" italic branch = "#2CB494" header = "#CCE0D0" [color "diff"] diff --git a/home/.tmux.conf b/home/.tmux.conf index f648fb8..0f2d36b 100644 --- a/home/.tmux.conf +++ b/home/.tmux.conf @@ -63,8 +63,8 @@ set -g status-position bottom set -g status-interval 1 set -g status-style "fg=#728cb8,bg=default" set -g status-left "#{?client_prefix,#[fg=#2cb494]● ,#[fg=#3c3c3c]● }" -set -g status-right "#(~/.tmux/battery.sh) #[fg=#808080,bg=default]%a %d %b #[fg=#2cb494,bg=#1a1a1a] %H:%M #[default] " -set -g status-right-length 60 +set -g status-right "#(~/.tmux/network.sh) #[fg=#3c3c3c] #(~/.tmux/battery.sh) #[fg=#3c3c3c] #[fg=#808080]%a %d %b #[fg=#2cb494,bg=#1a1a1a] %H:%M #[default] " +set -g status-right-length 80 set -g window-status-format "#{?window_last_flag, #[fg=#1a7a64]#I#[fg=default] #W , #I #W }" set -g window-status-current-format " #[fg=#085040]#I#[fg=#0a0a0a] #W " set -g window-status-separator " " diff --git a/home/.tmux/network.sh b/home/.tmux/network.sh new file mode 100755 index 0000000..dd5af8b --- /dev/null +++ b/home/.tmux/network.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +# Network indicator for tmux status bar. +# Pings 1.1.1.1 to measure latency, detects wired vs wifi. +# Caches result for 10s to avoid excessive pinging. + +cache="${TMPDIR:-/tmp}/.tmux_network_cache" + +# Return cached result if fresh (<10s old) +if [[ -f "$cache" ]]; then + age=$(( $(date +%s) - $(stat -f%m "$cache" 2>/dev/null || stat -c%Y "$cache" 2>/dev/null || echo 0) )) + if (( age < 10 )); then + cat "$cache" + exit 0 + fi +fi + +# Detect connection type +wired=1 +if [[ "$(uname)" == "Darwin" ]]; then + iface=$(route -n get default 2>/dev/null | awk '/interface:/{print $2}') + if networksetup -listallhardwareports 2>/dev/null | grep -A1 'Wi-Fi' | grep -q "$iface"; then + wired="" + fi +else + iface=$(ip route show default 2>/dev/null | awk '{print $5; exit}') + [[ -d "/sys/class/net/${iface}/wireless" ]] && wired="" +fi + +# Measure latency +ms="" +if [[ "$(uname)" == "Darwin" ]]; then + ms=$(ping -c1 -t1 1.1.1.1 2>/dev/null | awk '/time=/{gsub(/.*time=/,""); printf "%.0f", $1}') +else + ms=$(ping -c1 -W1 1.1.1.1 2>/dev/null | awk '/time=/{gsub(/.*time=/,""); printf "%.0f", $1}') +fi + +# Pick icon: wired 󰈀 vs wifi 󰤨 +if [[ -n "$wired" ]]; then + icon="󰈀" +else + icon="󰤨" +fi + +if [[ -z "$ms" ]]; then + result="#[fg=#F40404]󰤭 --#[default]" +elif (( ms <= 50 )); then + result="#[fg=#808080]${icon} ${ms}ms#[default]" +elif (( ms <= 150 )); then + result="#[fg=#f88c14]${icon} ${ms}ms#[default]" +else + result="#[fg=#F40404]${icon} ${ms}ms#[default]" +fi + +echo "$result" | tee "$cache" diff --git a/home/.zsh/prompt.zsh b/home/.zsh/prompt.zsh index f4ba577..d438232 100644 --- a/home/.zsh/prompt.zsh +++ b/home/.zsh/prompt.zsh @@ -145,7 +145,7 @@ _dots_git_info_sync() { elif [[ "$branch" == (main|master) ]]; then branch_pill="${_dots_pc[dark_bg]}${_dots_pc[dark]}(${_dots_pc[grey]}${branch}${_dots_pc[reset]}${_dots_pc[dark_bg]}${_dots_pc[dark]})${_dots_pc[reset]}" else - branch_pill="${_dots_pc[dark_bg]}${_dots_pc[dark]}(${_dots_pc[purple]}${_dots_pc[bold]}${branch}${_dots_pc[reset]}${_dots_pc[dark_bg]}${_dots_pc[dark]})${_dots_pc[reset]}" + branch_pill="${_dots_pc[dark_bg]}${_dots_pc[dark]}(${_dots_pc[purple]}${branch}${_dots_pc[reset]}${_dots_pc[dark_bg]}${_dots_pc[dark]})${_dots_pc[reset]}" fi local info="$branch_pill" @@ -156,11 +156,11 @@ _dots_git_info_sync() { sep=" " fi if (( unstaged )); then - dirty+="${sep}${_dots_pc[orange]}~${unstaged}" + dirty+="${sep}${_dots_pc[grey]}~${unstaged}" sep=" " fi if (( untracked )); then - dirty+="${sep}${_dots_pc[grey]}?${untracked}" + dirty+="${sep}${_dots_pc[orange]}?${untracked}" fi local arrows="" diff --git a/home/.zsh/widgets.zsh b/home/.zsh/widgets.zsh index cfc1ec1..50b8f17 100644 --- a/home/.zsh/widgets.zsh +++ b/home/.zsh/widgets.zsh @@ -53,10 +53,10 @@ _dots_load_keybindings() { for (f in git) printf "100000\t%s\t%s\n", clr(git[f]), f } function clr(st) { - if (st ~ /^\?\?/) return "\033[90m?\033[0m" + if (st ~ /^\?\?/) return "\033[33m?\033[0m" if (st ~ /^R/) return "\033[36mR\033[0m" if (st ~ /^A/) return "\033[32mA\033[0m" - if (st ~ /M/) return "\033[33mM\033[0m" + if (st ~ /M/) return "\033[38;5;103mM\033[0m" return "\033[90m~\033[0m" }' /dev/null 2>/dev/null | sort -rn | cut -f2- rg --files --hidden --glob '!.git' 2>/dev/null | awk '{print " \t" $0}'