From 88b0f52cc525a3f626dcf78dc8d7c63be2a92621 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Thu, 28 May 2026 11:15:00 +0300 Subject: [PATCH] added bmux --- README.md | 1 + bmux | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100755 bmux diff --git a/README.md b/README.md index 63708f3..b337163 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,4 @@ For POSIX shell compatible scripts, see the [sh-goodies](https://codeberg.org/lu * [YouStore](./ys): a way to securely store any set of files/directories inside a video * [1DLife](./1dlife): Jon Millen's 1D Game of Life in pure Bash +* [bmux](./bmux): a simple, dmux-like session manager in Bash on top of just dtach diff --git a/bmux b/bmux new file mode 100755 index 0000000..c3fd1fa --- /dev/null +++ b/bmux @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# bmux: a simple terminal session switcher in Bash on top of dtach +# Created by Luxferre in 2026, released into the public domain + +SDIR="$HOME/.dtsess" +SPFILE="$SDIR/.list" +mkdir -p "$SDIR" +touch "$SPFILE" +if [[ -z "$(ls -1 "$SDIR")" ]]; then + cat "$SPFILE" | while read -r sess; do + dtach -n "$SDIR/$sess" $SHELL + done +fi +PS3='Select a session: ' +mapfile -t MENU < "$SPFILE" +while true; do + select sname in "${MENU[@]}" New Quit; do break; done + [[ "$sname" = 'Quit' ]] && printf '\033[0m' && break + [[ "$sname" = 'New' ]] && read -r -p 'New session name: ' sname + [[ -n "$sname" ]] && printf '\033[0m' && dtach -A "$SDIR/$sname" $SHELL + ls -1 "$SDIR" > "$SPFILE" + mapfile -t MENU < "$SPFILE" +done