From 6999f19b0a4cca9cb9295910ce91226a3f000be3 Mon Sep 17 00:00:00 2001 From: "thomas.kopp" Date: Sat, 8 Aug 2026 22:42:19 +0200 Subject: [PATCH] fix: resolve powerline's tmux bindings instead of pinning a Python version tmux.conf sourced /usr/lib/python3.11/site-packages/powerline/bindings/tmux/powerline.conf which puts a Python minor version in a path. It was already wrong before this repository touched anything: beastix runs 3.14, so tmux has been printing that error there for however long. shron never had the problem because its own tmux.conf had the line commented out - until the checkout replaced that file with this copy, and every session there started with the error. Replacing a deliberately disabled setting with a broken one is the worse of the two outcomes, and it is exactly what "every machine carries every file" costs when a file is not actually machine-neutral. The path now comes from the module itself, so it survives Python upgrades, and each step exits quietly if something is missing. The Mac has neither powerline nor tmux and gets nothing. Co-Authored-By: Claude Opus 5 --- .scripts/tmux-powerline.sh | 28 ++++++++++++++++++++++++++++ tmux.conf | 6 ++++-- 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100755 .scripts/tmux-powerline.sh diff --git a/.scripts/tmux-powerline.sh b/.scripts/tmux-powerline.sh new file mode 100755 index 0000000..5a1d76d --- /dev/null +++ b/.scripts/tmux-powerline.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# Load powerline's tmux bindings, if powerline is installed at all. +# +# tmux.conf used to source +# /usr/lib/python3.11/site-packages/powerline/bindings/tmux/powerline.conf +# which pins a Python minor version into a path. That breaks on every Python +# upgrade and had already broken everywhere: beastix is on 3.14, and shron had +# the line commented out entirely until a checkout replaced its tmux.conf with +# a copy carrying the dead path. Every tmux session there then opened with +# No such file or directory: /usr/lib/python3.11/... +# +# Resolving the path from the module itself keeps it correct across upgrades, +# and every step is allowed to fail quietly so a machine without powerline - +# the Mac has neither it nor tmux - simply gets nothing. +set -u + +command -v powerline-daemon >/dev/null 2>&1 || exit 0 +command -v python3 >/dev/null 2>&1 || exit 0 + +powerline-daemon -q 2>/dev/null || exit 0 + +dir=$(python3 -c 'import os, powerline; print(os.path.dirname(powerline.__file__))' 2>/dev/null) || exit 0 +[ -n "$dir" ] || exit 0 + +conf="$dir/bindings/tmux/powerline.conf" +[ -r "$conf" ] || exit 0 + +tmux source-file "$conf" diff --git a/tmux.conf b/tmux.conf index 701c08c..1f3d659 100644 --- a/tmux.conf +++ b/tmux.conf @@ -143,8 +143,10 @@ bind S split-window -v #https://github.com/thewtex/tmux-mem-cpu-load #set -g status-interval 2 #set -g status-right "#(tmux-mem-cpu-load 2) #H" -run-shell "powerline-daemon -q" -source '/usr/lib/python3.11/site-packages/powerline/bindings/tmux/powerline.conf' +# powerline, resolved at runtime rather than pinned to a Python version. +# See .scripts/tmux-powerline.sh - the old hardcoded path was already wrong on +# every machine and made tmux print an error on every start. +run-shell "$HOME/.scripts/tmux-powerline.sh" # disable mouse control by default - change 'off' to 'on' to enable by default. setw -g mouse off