This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.zsh: add tmux session chooser for SSH connections

When SSHing into a machine with existing tmux sessions, show an fzf
picker instead of always creating a new session. The picker shows
session name, window count, creation time, and attach status.

- Preview pane shows the current content of each session (via capture-pane)
- DEL key kills the highlighted session and refreshes the list
- Selecting a session attaches to it
- Selecting '>>> new session <<<' or pressing ESC creates a new one
- Local terminals are unaffected, only triggers when SSH_CLIENT is set

+37 -2
+11 -2
tools/pi/flake-module.nix
··· 6 6 piPkg = self.legacyPackages.${system}.llm.pi; 7 7 8 8 # Pre-install pi plugins into a fake npm global prefix 9 - pluginPrefix = 10 - pkgs.runCommand "pi-plugins" 9 + pluginPrefixRaw = 10 + pkgs.runCommand "pi-plugins-raw" 11 11 { 12 12 nativeBuildInputs = [ 13 13 pkgs.nodejs ··· 27 27 export npm_config_prefix=$out 28 28 npm install -g pi-hooks shitty-extensions 29 29 ''; 30 + 31 + # Remove the resistance extension (annoying terminator quote widget) 32 + pluginPrefix = pkgs.runCommand "pi-plugins" { } '' 33 + cp -a ${pluginPrefixRaw} $out 34 + chmod -R u+w $out 35 + pkg=$out/lib/node_modules/shitty-extensions/package.json 36 + ${pkgs.jq}/bin/jq '.pi.extensions |= map(select(contains("resistance") | not))' "$pkg" > "$pkg.tmp" 37 + mv "$pkg.tmp" "$pkg" 38 + ''; 30 39 in 31 40 { 32 41 packages.pi = self.wrapLib.makeWrapper {
+26
tools/zsh/flake-module.nix
··· 272 272 tmux set-environment -g SSH_AUTH_SOCK "$SSH_AUTH_SOCK" 2>/dev/null 273 273 fi 274 274 275 + # SSH session chooser: show existing sessions via fzf 276 + # Delete key kills the highlighted session, then refreshes the list 277 + if [[ -n "$SSH_CLIENT" ]]; then 278 + while true; do 279 + existing=$(tmux list-sessions -F '#{session_name}: #{session_windows} windows (created #{session_created_string})#{?session_attached, (attached),}' 2>/dev/null) 280 + [[ -z "$existing" ]] && break 281 + chosen=$(echo ">>> new session <<<\n$existing" \ 282 + | fzf --height=80% --reverse \ 283 + --header="Pick a tmux session (DEL to kill)" \ 284 + --expect=delete \ 285 + --preview='s={1}; s=''${s%:}; [ "$s" = ">>>" ] && echo "Create a new session" || tmux capture-pane -t "$s" -p -e 2>/dev/null' \ 286 + --preview-window=right:60%) 287 + key=$(echo "$chosen" | head -1) 288 + selection=$(echo "$chosen" | tail -1) 289 + chosen_name=$(echo "$selection" | cut -d: -f1) 290 + if [[ "$key" == "delete" && -n "$chosen_name" && "$chosen_name" != ">>> new session <<<" ]]; then 291 + tmux kill-session -t "$chosen_name" 2>/dev/null 292 + continue 293 + fi 294 + if [[ -n "$chosen_name" && "$chosen_name" != ">>> new session <<<" ]]; then 295 + exec tmux -u attach -t "$chosen_name" 296 + fi 297 + break 298 + done 299 + fi 300 + 275 301 # Generate a readable session name using name-generator 276 302 session_name=$(${ 277 303 self.packages.${pkgs.system}.name-generator